pub struct ContainerAsync<T, Manager> { /* private fields */ }
Available on crate feature shared-async only.
Expand description

A container that allows shared, asynchronous, thread-safe access to a file and its underlying contents. The in-memory A container that allows atomic reference-counted, asynchronous, mutable access (gated by an RwLock) to the underlying file and contents.

Implementations

Gets a reference to the contained file manager.

It is inadvisable to manipulate the manager manually.

Gets immutable access to the underlying value T.

Gets mutable access to the underlying value T.

Gets immutable access to the underlying value T.

Gets mutable access to the underlying value T.

Grants the caller immutable access to the underlying value T, but only for the duration of the provided function or closure.

Grants the caller mutable access to the underlying value T, but only for the duration of the provided function or closure.

Opens a new ContainerAsync, returning an error if the file at the given path does not exist.

Opens a new ContainerAsync, writing the given value to the file if it does not exist.

Opens a new ContainerAsync, writing the result of the given closure to the file if it does not exist.

Opens a new ContainerAsync, writing the default value of T to the file if it does not exist.

Reads a value from the managed file, replacing the current state in memory, immediately granting the caller immutable access to that state for the duration of the provided function or closure.

The provided closure takes (1) a reference to the new state, and (2) the old state.

This function acquires a mutable lock on the shared state.

Grants the caller mutable access to the underlying value T, but only for the duration of the provided function or closure, immediately committing any changes made as long as no error was returned.

This function acquires a mutable lock on the shared state.

Reads a value from the managed file, replacing the current state in memory.

Returns the value of the previous state if the operation succeeded.

This function acquires an immutable lock on the shared state.

Writes the current in-memory state to the managed file.

This function acquires an immutable lock on the shared state. Don’t call this if you currently have an access guard, use ContainerAsync::commit_guard instead.

Writes to the managed file given an access guard.

Writes the given state to the managed file, replacing the in-memory state.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Converts to this type from the input type.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.