Skip to main content

Storage

Trait Storage 

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

    // Required methods
    fn store(
        &self,
        namespace: &NamespaceName,
        seg: Self::Segment,
        config_override: Option<Self::Config>,
        on_store: OnStoreCallback,
    );
    fn durable_frame_no(
        &self,
        namespace: &NamespaceName,
        config_override: Option<Self::Config>,
    ) -> impl Future<Output = Result<u64>> + Send;
    async fn restore(
        &self,
        file: impl FileExt,
        namespace: &NamespaceName,
        restore_options: RestoreOptions,
        config_override: Option<Self::Config>,
    ) -> Result<()>;
    fn find_segment(
        &self,
        namespace: &NamespaceName,
        frame_no: FindSegmentReq,
        config_override: Option<Self::Config>,
    ) -> impl Future<Output = Result<SegmentKey>> + Send;
    fn fetch_segment_index(
        &self,
        namespace: &NamespaceName,
        key: &SegmentKey,
        config_override: Option<Self::Config>,
    ) -> impl Future<Output = Result<Map<Arc<[u8]>>>> + Send;
    fn fetch_segment_data(
        &self,
        namespace: &NamespaceName,
        key: &SegmentKey,
        config_override: Option<Self::Config>,
    ) -> impl Future<Output = Result<CompactedSegment<impl FileExt>>> + Send;
    fn list_segments<'a>(
        &'a self,
        namespace: &'a NamespaceName,
        until: u64,
        config_override: Option<Self::Config>,
    ) -> impl Stream<Item = Result<SegmentInfo>> + 'a;

    // Provided method
    fn shutdown(&self) -> impl Future<Output = ()> + Send { ... }
}

Required Associated Types§

Required Methods§

Source

fn store( &self, namespace: &NamespaceName, seg: Self::Segment, config_override: Option<Self::Config>, on_store: OnStoreCallback, )

store the passed segment for namespace. This function is called in a context where blocking is acceptable. returns a future that resolves when the segment is stored The segment should be stored whether or not the future is polled.

Source

fn durable_frame_no( &self, namespace: &NamespaceName, config_override: Option<Self::Config>, ) -> impl Future<Output = Result<u64>> + Send

Source

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

Source

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

Source

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

Source

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

Source

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

Provided Methods§

Source

fn shutdown(&self) -> impl Future<Output = ()> + Send

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<A, B, S> Storage for Either<A, B>
where A: Storage<Segment = S>, B: Storage<Segment = S>, S: Segment,

Source§

type Segment = S

Source§

type Config = Either<<A as Storage>::Config, <B as Storage>::Config>

Source§

fn store( &self, namespace: &NamespaceName, seg: Self::Segment, config_override: Option<Self::Config>, on_store: OnStoreCallback, )

Source§

async fn durable_frame_no( &self, namespace: &NamespaceName, config_override: Option<Self::Config>, ) -> Result<u64>

Source§

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

Source§

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

Source§

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

Source§

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

Source§

async fn shutdown(&self)

Source§

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

Implementors§