Trait Backend

Source
pub trait Backend:
    Send
    + Sync
    + 'static {
    type Config: Clone + Send + Sync + 'static;

    // Required methods
    fn store(
        &self,
        config: &Self::Config,
        meta: SegmentMeta,
        segment_data: impl FileExt,
        segment_index: Vec<u8>,
    ) -> impl Future<Output = Result<()>> + Send;
    fn find_segment(
        &self,
        config: &Self::Config,
        namespace: &NamespaceName,
        req: FindSegmentReq,
    ) -> impl Future<Output = Result<SegmentKey>> + Send;
    fn fetch_segment_index(
        &self,
        config: &Self::Config,
        namespace: &NamespaceName,
        key: &SegmentKey,
    ) -> impl Future<Output = Result<Map<Arc<[u8]>>>> + Send;
    async fn fetch_segment_data_to_file(
        &self,
        config: &Self::Config,
        namespace: &NamespaceName,
        key: &SegmentKey,
        file: &impl FileExt,
    ) -> Result<CompactedSegmentDataHeader>;
    fn fetch_segment_data(
        self: Arc<Self>,
        config: Self::Config,
        namespace: NamespaceName,
        key: SegmentKey,
    ) -> impl Future<Output = Result<impl FileExt>> + Send;
    fn meta(
        &self,
        config: &Self::Config,
        namespace: &NamespaceName,
    ) -> impl Future<Output = Result<DbMeta>> + Send;
    async fn restore(
        &self,
        config: &Self::Config,
        namespace: &NamespaceName,
        restore_options: RestoreOptions,
        dest: impl FileExt,
    ) -> Result<()>;
    fn list_segments<'a>(
        &'a self,
        config: Self::Config,
        namespace: &'a NamespaceName,
        until: u64,
    ) -> impl Stream<Item = Result<SegmentInfo>> + 'a;
    fn default_config(&self) -> Self::Config;
}

Required Associated Types§

Source

type Config: Clone + Send + Sync + 'static

Config type associated with the Storage

Required Methods§

Source

fn store( &self, config: &Self::Config, meta: SegmentMeta, segment_data: impl FileExt, segment_index: Vec<u8>, ) -> impl Future<Output = Result<()>> + Send

Store segment_data with its associated meta

Source

fn find_segment( &self, config: &Self::Config, namespace: &NamespaceName, req: FindSegmentReq, ) -> impl Future<Output = Result<SegmentKey>> + Send

Source

fn fetch_segment_index( &self, config: &Self::Config, namespace: &NamespaceName, key: &SegmentKey, ) -> impl Future<Output = Result<Map<Arc<[u8]>>>> + Send

Source

async fn fetch_segment_data_to_file( &self, config: &Self::Config, namespace: &NamespaceName, key: &SegmentKey, file: &impl FileExt, ) -> Result<CompactedSegmentDataHeader>

Fetch a segment for namespace containing frame_no, and writes it to dest.

Source

fn fetch_segment_data( self: Arc<Self>, config: Self::Config, namespace: NamespaceName, key: SegmentKey, ) -> impl Future<Output = Result<impl FileExt>> + Send

Source

fn meta( &self, config: &Self::Config, namespace: &NamespaceName, ) -> impl Future<Output = Result<DbMeta>> + Send

Fetch meta for namespace

Source

async fn restore( &self, config: &Self::Config, namespace: &NamespaceName, restore_options: RestoreOptions, dest: impl FileExt, ) -> Result<()>

Source

fn list_segments<'a>( &'a self, config: Self::Config, namespace: &'a NamespaceName, until: u64, ) -> impl Stream<Item = Result<SegmentInfo>> + 'a

Source

fn default_config(&self) -> Self::Config

Returns the default configuration for this storage

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.

Implementations on Foreign Types§

Source§

impl<T: Backend> Backend for Arc<T>

Source§

type Config = <T as Backend>::Config

Source§

fn store( &self, config: &Self::Config, meta: SegmentMeta, segment_data: impl FileExt, segment_index: Vec<u8>, ) -> impl Future<Output = Result<()>> + Send

Source§

async fn meta( &self, config: &Self::Config, namespace: &NamespaceName, ) -> Result<DbMeta>

Source§

fn default_config(&self) -> Self::Config

Source§

async fn restore( &self, config: &Self::Config, namespace: &NamespaceName, restore_options: RestoreOptions, dest: impl FileExt, ) -> Result<()>

Source§

async fn find_segment( &self, config: &Self::Config, namespace: &NamespaceName, req: FindSegmentReq, ) -> Result<SegmentKey>

Source§

async fn fetch_segment_index( &self, config: &Self::Config, namespace: &NamespaceName, key: &SegmentKey, ) -> Result<Map<Arc<[u8]>>>

Source§

async fn fetch_segment_data_to_file( &self, config: &Self::Config, namespace: &NamespaceName, key: &SegmentKey, file: &impl FileExt, ) -> Result<CompactedSegmentDataHeader>

Source§

async fn fetch_segment_data( self: Arc<Self>, config: Self::Config, namespace: NamespaceName, key: SegmentKey, ) -> Result<impl FileExt>

Source§

fn list_segments<'a>( &'a self, config: Self::Config, namespace: &'a NamespaceName, until: u64, ) -> impl Stream<Item = Result<SegmentInfo>> + 'a

Implementors§

Source§

impl<IO> Backend for S3Backend<IO>
where IO: Io,