struct Config {
file: PathBuf,
inner: InnerConfig,
lock_task: Option<JoinHandle<Result<()>>>,
}
Expand description
Account manager configuration file.
Fields§
§file: PathBuf
§inner: InnerConfig
§lock_task: Option<JoinHandle<Result<()>>>
Implementations§
source§impl Config
impl Config
async fn create_lock_task( dir: PathBuf, ) -> Result<Option<JoinHandle<Result<()>>>>
sourceasync fn new_nosync(file: PathBuf, lock: bool) -> Result<Self>
async fn new_nosync(file: PathBuf, lock: bool) -> Result<Self>
Creates a new Config for file
, but doesn’t open/sync it.
sourcepub async fn new(dir: &Path) -> Result<Self>
pub async fn new(dir: &Path) -> Result<Self>
Creates a new configuration file in the given account manager directory.
sourceasync fn sync(&mut self) -> Result<()>
async fn sync(&mut self) -> Result<()>
Sync the inmemory representation to disk.
Takes a mutable reference because the saved file is a part of the Config
state. This
protects from parallel calls resulting to a wrong file contents.
sourcepub async fn from_file(file: PathBuf, writable: bool) -> Result<Self>
pub async fn from_file(file: PathBuf, writable: bool) -> Result<Self>
Read a configuration from the given file into memory.
sourcepub async fn load_accounts(
&self,
events: &Events,
stockstrings: &StockStrings,
push_subscriber: PushSubscriber,
dir: &Path,
) -> Result<BTreeMap<u32, Context>>
pub async fn load_accounts( &self, events: &Events, stockstrings: &StockStrings, push_subscriber: PushSubscriber, dir: &Path, ) -> Result<BTreeMap<u32, Context>>
Loads all accounts defined in the configuration file.
Created contexts share the same event channel and stock string translations.
sourceasync fn new_account(&mut self) -> Result<AccountConfig>
async fn new_account(&mut self) -> Result<AccountConfig>
Creates a new account in the account manager directory.
sourcepub async fn remove_account(&mut self, id: u32) -> Result<()>
pub async fn remove_account(&mut self, id: u32) -> Result<()>
Removes an existing account entirely.
sourcefn get_account(&self, id: u32) -> Option<AccountConfig>
fn get_account(&self, id: u32) -> Option<AccountConfig>
Returns configuration file section for the given account ID.
sourcepub fn get_selected_account(&self) -> u32
pub fn get_selected_account(&self) -> u32
Returns the ID of selected account.
sourcepub async fn select_account(&mut self, id: u32) -> Result<()>
pub async fn select_account(&mut self, id: u32) -> Result<()>
Changes selected account ID.