pub struct StoreBuilder<'a, T: Sized + Serialize> { /* private fields */ }Expand description
Builder for storing a value with fine-grained options.
Created via StoreConfigFile::store_opts. Configure with
pretty, overwrite and
format, then call
execute to write the file.
Defaults: pretty on, overwrite on, format auto-detected from the path
extension (i.e. the same behavior as StoreConfigFile::store).
Implementations§
Source§impl<'a, T: Sized + Serialize> StoreBuilder<'a, T>
impl<'a, T: Sized + Serialize> StoreBuilder<'a, T>
Sourcepub const fn pretty(self, pretty: bool) -> Self
pub const fn pretty(self, pretty: bool) -> Self
Toggle pretty-printing. Default: true. Formats without a pretty
variant (xml/yaml/json5) ignore this.
Sourcepub const fn overwrite(self, overwrite: bool) -> Self
pub const fn overwrite(self, overwrite: bool) -> Self
Toggle overwriting an existing file. Default: true. When false,
execute returns Error::FileExists if the
file already exists.
Sourcepub const fn format(self, config_format: ConfigFormat) -> Self
pub const fn format(self, config_format: ConfigFormat) -> Self
Use a specific ConfigFormat, overriding extension-based detection.
Sourcepub fn execute(&self) -> Result<()>
pub fn execute(&self) -> Result<()>
Store the value with the configured options.
§Errors
- Returns
Error::UnsupportedFormatif the format can’t be determined. - Returns
Error::FileAccessif the file can’t be written. - Returns
Error::FileExistsifoverwriteisfalseand the file exists. - Returns
Error::<Format>on serialization failure.
Trait Implementations§
Auto Trait Implementations§
impl<'a, T> Freeze for StoreBuilder<'a, T>
impl<'a, T> RefUnwindSafe for StoreBuilder<'a, T>where
T: RefUnwindSafe,
impl<'a, T> Send for StoreBuilder<'a, T>where
T: Sync,
impl<'a, T> Sync for StoreBuilder<'a, T>where
T: Sync,
impl<'a, T> Unpin for StoreBuilder<'a, T>
impl<'a, T> UnsafeUnpin for StoreBuilder<'a, T>
impl<'a, T> UnwindSafe for StoreBuilder<'a, T>where
T: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more