Skip to main content

StandardManager

Struct StandardManager 

Source
pub struct StandardManager<Format> { /* private fields */ }
Expand description

A standard implementation of FileManager. Provides options for file locking and file modes.

Trait Implementations§

Source§

impl<Format: Debug> Debug for StandardManager<Format>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T, Format> FileManager<T> for StandardManager<Format>
where Format: FileFormat<T>,

Source§

type Format = Format

The FileFormat of this FileManager.
Source§

type Options = StandardManagerOptions

Specifies the behavior of the FileManager, required on instantiation.
Source§

type Error = Error<<<StandardManager<Format> as FileManager<T>>::Format as FileFormat<T>>::FormatError>

The error type returned by methods of this FileManager.
Source§

fn open<P: AsRef<Path>>( path: P, format: Self::Format, options: Self::Options, ) -> Result<Self, Self::Error>

Open a new instance of this FileManager, returning an error if the file at the given path does not exist.
Source§

fn read(&mut self) -> Result<T, Self::Error>

Reads a value from the file managed by this FileManager.
Source§

fn write(&mut self, value: &T) -> Result<(), Self::Error>

Writes a value to the file managed by this FileManager.
Source§

fn into_inner(self) -> Result<(Format, Self::Options), Self::Error>

Closes this FileManager, returning the Format and Options parameters used to construct it.
Source§

fn create_overwrite<P: AsRef<Path>>( path: P, format: Self::Format, options: Self::Options, value: T, ) -> Result<(T, Self), Self::Error>

Open a new instance of this FileManager, creating a file at the given path if it does not exist, and overwriting its contents if it does.
Source§

fn create_or<P: AsRef<Path>>( path: P, format: Self::Format, options: Self::Options, value: T, ) -> Result<(T, Self), Self::Error>

Open a new instance of this FileManager, writing the given value to the file if it does not exist.
Source§

fn create_or_else<P: AsRef<Path>>( path: P, format: Self::Format, options: Self::Options, closure: impl FnOnce() -> T, ) -> Result<(T, Self), Self::Error>

Open a new instance of this FileManager, writing the result of the given closure to the file if it does not exist.
Source§

fn create_or_default<P: AsRef<Path>>( path: P, format: Self::Format, options: Self::Options, ) -> Result<(T, Self), Self::Error>
where T: Default,

Open a new instance of this FileManager, writing the default value of T to the file if it does not exist.
Source§

fn close(self) -> Result<(), Self::Error>

Closes this FileManager.

Auto Trait Implementations§

§

impl<Format> Freeze for StandardManager<Format>
where Format: Freeze,

§

impl<Format> RefUnwindSafe for StandardManager<Format>
where Format: RefUnwindSafe,

§

impl<Format> Send for StandardManager<Format>
where Format: Send,

§

impl<Format> Sync for StandardManager<Format>
where Format: Sync,

§

impl<Format> Unpin for StandardManager<Format>
where Format: Unpin,

§

impl<Format> UnsafeUnpin for StandardManager<Format>
where Format: UnsafeUnpin,

§

impl<Format> UnwindSafe for StandardManager<Format>
where Format: 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.