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§
Sourcefn store(
&self,
namespace: &NamespaceName,
seg: Self::Segment,
config_override: Option<Self::Config>,
on_store: OnStoreCallback,
)
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.
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 Methods§
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.