2023-04-03 13:46:04 -07:00
|
|
|
//! Theseus profile management interface
|
2023-06-30 08:11:32 -07:00
|
|
|
|
2023-04-03 13:46:04 -07:00
|
|
|
pub use crate::{
|
|
|
|
|
state::{
|
|
|
|
|
Hooks, JavaSettings, MemorySettings, Profile, Settings, WindowSize,
|
|
|
|
|
},
|
|
|
|
|
State,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/// Gets entire settings
|
|
|
|
|
#[tracing::instrument]
|
|
|
|
|
pub async fn get() -> crate::Result<Settings> {
|
|
|
|
|
let state = State::get().await?;
|
|
|
|
|
let settings = state.settings.read().await;
|
|
|
|
|
Ok(settings.clone())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Sets entire settings
|
|
|
|
|
#[tracing::instrument]
|
|
|
|
|
pub async fn set(settings: Settings) -> crate::Result<()> {
|
|
|
|
|
let state = State::get().await?;
|
2023-05-08 12:14:08 -07:00
|
|
|
let (reset_io, reset_fetch) = async {
|
|
|
|
|
let read = state.settings.read().await;
|
|
|
|
|
(
|
|
|
|
|
settings.max_concurrent_writes != read.max_concurrent_writes,
|
|
|
|
|
settings.max_concurrent_downloads != read.max_concurrent_downloads,
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
.await;
|
|
|
|
|
|
2023-05-23 14:24:39 -07:00
|
|
|
{
|
|
|
|
|
*state.settings.write().await = settings;
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-08 12:14:08 -07:00
|
|
|
if reset_io {
|
|
|
|
|
state.reset_io_semaphore().await;
|
|
|
|
|
}
|
|
|
|
|
if reset_fetch {
|
|
|
|
|
state.reset_fetch_semaphore().await;
|
|
|
|
|
}
|
2023-05-23 14:24:39 -07:00
|
|
|
|
2023-04-19 11:44:44 -07:00
|
|
|
State::sync().await?;
|
2023-04-03 13:46:04 -07:00
|
|
|
Ok(())
|
2023-04-05 10:07:59 -07:00
|
|
|
}
|