Trait vmcore::non_volatile_store::NonVolatileStore

source ·
pub trait NonVolatileStore: Send + Sync {
    // Required methods
    fn persist<'life0, 'async_trait>(
        &'life0 mut self,
        data: Vec<u8>,
    ) -> Pin<Box<dyn Future<Output = Result<(), NonVolatileStoreError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn restore<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, NonVolatileStoreError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Save and restore hunks of data to a non-volatile storage medium.

E.g: certain devices contain onboard non-volatile storage (e.g: UEFI’s nvram variables, the TPM’s internal state, etc…) that must be persisted across reboots.

This trait provides a generic mechanism for persisting / restoring this kind of non-volatile data, while leaving the details of how it gets stored to supporting infrastructure.

Required Methods§

source

fn persist<'life0, 'async_trait>( &'life0 mut self, data: Vec<u8>, ) -> Pin<Box<dyn Future<Output = Result<(), NonVolatileStoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Write data to a non-volatile storage medium.

source

fn restore<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, NonVolatileStoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Read any previously written data. Returns None if no data exists.

Trait Implementations§

source§

impl NonVolatileStore for Box<dyn NonVolatileStore>

source§

fn persist<'life0, 'async_trait>( &'life0 mut self, data: Vec<u8>, ) -> Pin<Box<dyn Future<Output = Result<(), NonVolatileStoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Write data to a non-volatile storage medium.
source§

fn restore<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, NonVolatileStoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Read any previously written data. Returns None if no data exists.

Implementations on Foreign Types§

source§

impl NonVolatileStore for Box<dyn NonVolatileStore>

source§

fn persist<'life0, 'async_trait>( &'life0 mut self, data: Vec<u8>, ) -> Pin<Box<dyn Future<Output = Result<(), NonVolatileStoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

source§

fn restore<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, NonVolatileStoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

source§

impl<T> NonVolatileStore for &mut T

source§

fn persist<'life0, 'async_trait>( &'life0 mut self, data: Vec<u8>, ) -> Pin<Box<dyn Future<Output = Result<(), NonVolatileStoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

source§

fn restore<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, NonVolatileStoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Implementors§