Trait koit_toml::backend::Backend[][src]

pub trait Backend {
    type Error: Error + Send + Sync + 'static;
    #[must_use]
    fn read<'life0, 'async_trait>(
        &'life0 mut self
    ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, Self::Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
#[must_use] fn write<'life0, 'async_trait>(
        &'life0 mut self,
        data: Vec<u8>
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
; }
Expand description

Trait implementable by bytes storage providers.

Examples

See the backend module documentation.

Associated Types

type Error: Error + Send + Sync + 'static[src]

Required methods

#[must_use]
fn read<'life0, 'async_trait>(
    &'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, Self::Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

Read all data from the backend.

Errors

If the bytes failed to be read by the backend, an error variant is returned.

#[must_use]
fn write<'life0, 'async_trait>(
    &'life0 mut self,
    data: Vec<u8>
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

Overwrite the backend with the given data.

Errors

If the bytes failed to be written to the backend, an error variant is returned. This may mean the backend is now corrupted.

Implementors

impl Backend for File[src]

type Error = Error

fn read<'life0, 'async_trait>(
    &'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, Self::Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

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

impl Backend for Memory[src]

type Error = Infallible

fn read<'life0, 'async_trait>(
    &'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, Self::Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

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