mas_storage::policy_data

Trait PolicyDataRepository

Source
pub trait PolicyDataRepository: Send + Sync {
    type Error;

    // Required methods
    fn get<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<Option<PolicyData>, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn set<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 mut self,
        rng: &'life1 mut (dyn RngCore + Send),
        clock: &'life2 dyn Clock,
        data: Value,
    ) -> Pin<Box<dyn Future<Output = Result<PolicyData, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn prune<'life0, 'async_trait>(
        &'life0 mut self,
        keep: usize,
    ) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

A PolicyDataRepository helps interacting with the policy data saved in the storage backend.

Required Associated Types§

Source

type Error

The error type returned by the repository

Required Methods§

Source

fn get<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<Option<PolicyData>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the latest policy data

Returns the latest policy data, or None if no policy data is available.

§Errors

Returns Self::Error if the underlying repository fails

Source

fn set<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, rng: &'life1 mut (dyn RngCore + Send), clock: &'life2 dyn Clock, data: Value, ) -> Pin<Box<dyn Future<Output = Result<PolicyData, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Set the latest policy data

Returns the newly created policy data.

§Parameters
  • rng: The random number generator to use
  • clock: The clock used to generate the timestamps
  • data: The policy data to set
§Errors

Returns Self::Error if the underlying repository fails

Source

fn prune<'life0, 'async_trait>( &'life0 mut self, keep: usize, ) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Prune old policy data

Returns the number of entries pruned.

§Parameters
  • keep: the number of old entries to keep
§Errors

Returns Self::Error if the underlying repository fails

Implementations on Foreign Types§

Source§

impl<R> PolicyDataRepository for Box<R>

Source§

type Error = <R as PolicyDataRepository>::Error

Source§

fn get<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<Option<PolicyData>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn set<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, rng: &'life1 mut (dyn RngCore + Send), clock: &'life2 dyn Clock, data: Value, ) -> Pin<Box<dyn Future<Output = Result<PolicyData, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Source§

fn prune<'life0, 'async_trait>( &'life0 mut self, keep: usize, ) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Implementors§

Source§

impl<R, F, E> PolicyDataRepository for MapErr<R, F>

Source§

type Error = E