FidlStorage

Struct FidlStorage 

Source
pub struct FidlStorage { /* private fields */ }
Expand description

Stores device level settings in persistent storage. User level settings should not use this.

Implementations§

Source§

impl FidlStorage

Source

pub async fn with_file_proxy<I, G>( iter: I, storage_dir: DirectoryProxy, files_generator: G, ) -> Result<(Self, Vec<Task<()>>), Error>
where I: IntoIterator<Item = (&'static str, Option<Box<dyn Any>>)>, G: Fn(&'static str) -> Result<(String, String), Error>,

Construct a fidl storage from:

  • The iterable item, which will produce the keys for storage
  • A generator function that will produce a file proxy for each key. It will return the temp file path and final file path for storing the data for this key.

On success, returns the FidlStorage as well as the list of background synchronizing tasks. The background tasks can be awaited or detached.

Source

pub fn set_caching_enabled(&mut self, enabled: bool)

Source

pub fn set_debounce_writes(&mut self, debounce: bool)

Source

pub async fn write<T>(&self, new_value: T) -> Result<UpdateState, Error>

Write new_value to storage. The write will be persisted to disk at a set interval.

Source

pub async fn write_test_bytes( &self, key: &'static str, value: Vec<u8>, ) -> Result<(), Error>

Test-only method to write directly to disk without touching the cache. This is used for setting up data as if it existed on disk before the storage was constructed.

Source

pub async fn get<T>(&self) -> T

Gets the latest value cached locally, or loads the value from storage. Doesn’t support multiple concurrent callers of the same struct.

Auto Trait Implementations§

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, D> Encode<Ambiguous1, D> for T
where D: ResourceDialect,

Source§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
Source§

impl<T, D> Encode<Ambiguous2, D> for T
where D: ResourceDialect,

Source§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V