BucketLogProvider

Trait BucketLogProvider 

Source
pub trait BucketLogProvider:
    Send
    + Sync
    + Debug
    + Clone
    + 'static {
    type Error: Display + Debug;

    // Required methods
    fn exists<'life0, 'async_trait>(
        &'life0 self,
        id: Uuid,
    ) -> Pin<Box<dyn Future<Output = Result<bool, BucketLogError<Self::Error>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn heads<'life0, 'async_trait>(
        &'life0 self,
        id: Uuid,
        height: u64,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Link>, BucketLogError<Self::Error>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn append<'life0, 'async_trait>(
        &'life0 self,
        id: Uuid,
        name: String,
        current: Link,
        previous: Option<Link>,
        height: u64,
    ) -> Pin<Box<dyn Future<Output = Result<(), BucketLogError<Self::Error>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn height<'life0, 'async_trait>(
        &'life0 self,
        id: Uuid,
    ) -> Pin<Box<dyn Future<Output = Result<u64, BucketLogError<Self::Error>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn has<'life0, 'async_trait>(
        &'life0 self,
        id: Uuid,
        link: Link,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<u64>, BucketLogError<Self::Error>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn list_buckets<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Uuid>, BucketLogError<Self::Error>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn head<'life0, 'async_trait>(
        &'life0 self,
        id: Uuid,
        height: Option<u64>,
    ) -> Pin<Box<dyn Future<Output = Result<(Link, u64), BucketLogError<Self::Error>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}

Required Associated Types§

Required Methods§

Source

fn exists<'life0, 'async_trait>( &'life0 self, id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<bool, BucketLogError<Self::Error>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn heads<'life0, 'async_trait>( &'life0 self, id: Uuid, height: u64, ) -> Pin<Box<dyn Future<Output = Result<Vec<Link>, BucketLogError<Self::Error>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the possible heads for a bucket based on passed height

§Arguments
  • id - The UUID of the bucket
  • height - The height to query the candidate heads for
§Returns
  • Ok(Vec<Link>) - The candidate heads for the bucket
  • Err(Self::Error) - An error occurred while fetching the candidate heads
Source

fn append<'life0, 'async_trait>( &'life0 self, id: Uuid, name: String, current: Link, previous: Option<Link>, height: u64, ) -> Pin<Box<dyn Future<Output = Result<(), BucketLogError<Self::Error>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Append a version of the bucket to the log

§Arguments
  • id - The UUID of the bucket
  • name - The friendly name for the bucket
  • current - The current link of the record
  • previous - The previous link of the record
  • height - The reported depth of the bucket version within the chain

Should fail with the following errors to be considered correct:

  • Err(BucketLogError::Conflict) - The append causes a conflict with the current log
  • Err(BucketLogError::InvalidHeight) - The height is not greater than the previous height
Source

fn height<'life0, 'async_trait>( &'life0 self, id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<u64, BucketLogError<Self::Error>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Return the greatest height of the bucket version within the chain

§Arguments
  • id - The UUID of the bucket
§Returns
  • Result<u64, BucketLogError<Self::Error>> - The height of the bucket version within the chain

NOTE: while this returns a BucketLogError, it should only ever return a BucketLogError::NotFound or ProviderError

Source

fn has<'life0, 'async_trait>( &'life0 self, id: Uuid, link: Link, ) -> Pin<Box<dyn Future<Output = Result<Vec<u64>, BucketLogError<Self::Error>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Check if a link exists within a bucket

§Arguments
  • id - The UUID of the bucket
  • link - The link to check for existence as current
§Returns
  • Result<Vec<u64>, BucketLogError<Self::Error>> The heights at which the link exists within the bucket
Source

fn list_buckets<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<Uuid>, BucketLogError<Self::Error>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

List all bucket IDs that have log entries

§Returns
  • Ok(Vec<Uuid>) - The list of bucket IDs
  • Err(BucketLogError) - An error occurred while fetching bucket IDs

Provided Methods§

Source

fn head<'life0, 'async_trait>( &'life0 self, id: Uuid, height: Option<u64>, ) -> Pin<Box<dyn Future<Output = Result<(Link, u64), BucketLogError<Self::Error>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the peers canonical head based on its log entries

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§