Skip to main content

ConfigManager

Struct ConfigManager 

Source
pub struct ConfigManager<T> { /* private fields */ }

Implementations§

Source§

impl<T> ConfigManager<T>

Source

pub fn new() -> Self

デフォルト初期化 フォルダ: OS 標準 config ディレクトリ / app_name

Source

pub fn at_current_dir(self) -> Self

カレントディレクトリに保存

Source

pub fn at_custom_dir<P: Into<PathBuf>>(self, path: P) -> Self

任意パスに保存

Source

pub fn with_filename(self, name: &str) -> Self

ファイル名変更

Source

pub fn disable_pretty_json(self) -> Self

JSON を pretty 形式で保存

Source

pub fn path(&self) -> PathBuf

フルパス取得

Source

pub fn save(&self, config: &T) -> Result<()>

完全保存(置換書き込み)

Source

pub fn load(&self) -> Result<T>

ファイルが存在する前提のロード

Source§

impl<T> ConfigManager<T>

Source

pub fn load_or_default(&self) -> Result<T>

存在しなければ default を生成して保存

Source

pub fn update<F>(&self, f: F) -> Result<T>
where F: FnOnce(&mut T),

安全な read-modify-write save() と並ぶ主要 API

Auto Trait Implementations§

§

impl<T> Freeze for ConfigManager<T>

§

impl<T> RefUnwindSafe for ConfigManager<T>
where T: RefUnwindSafe,

§

impl<T> Send for ConfigManager<T>
where T: Send,

§

impl<T> Sync for ConfigManager<T>
where T: Sync,

§

impl<T> Unpin for ConfigManager<T>
where T: Unpin,

§

impl<T> UnwindSafe for ConfigManager<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.