pub struct Store<S, H> { /* private fields */ }
Expand description

Unit of persistence within a Segment.

segmented_log_segment

Fig: Segment diagram showing Store, persisting record bytes at positions mapped out by the Index records.

A Store contains a backing Storage impl instance to persist record bytes.

Implementations§

source§

impl<S, H> Store<S, H>

source

pub fn new(storage: S) -> Self

Creates a new Store instance from the given backing Storage instance.

source§

impl<S, H> Store<S, H>
where S: Storage, H: Hasher + Default,

source

pub async fn read( &self, position: &S::Position, record_header: &RecordHeader ) -> Result<S::Content, StoreError<S::Error>>

Reads record bytes for a record persisted at the given position with the designated RecordHeader.

source

pub async fn append<XBuf, X, XE>( &mut self, stream: X, append_threshold: Option<S::Size> ) -> Result<(S::Position, RecordHeader), StoreError<S::Error>>
where XBuf: Deref<Target = [u8]>, X: Stream<Item = Result<XBuf, XE>> + Unpin,

Appends the bytes for a new record at the end of this store.

Returns the computed RecordHeader for the provided record bytes along with the position where the record was written.

Trait Implementations§

source§

impl<S: Storage, H> AsyncConsume for Store<S, H>

§

type ConsumeError = StoreError<<S as Storage>::Error>

Error that can occur during a consumption operation.
source§

fn remove<'async_trait>( self ) -> Pin<Box<dyn Future<Output = Result<(), Self::ConsumeError>> + 'async_trait>>
where Self: 'async_trait,

Removes all storage associated with this collection. Read more
source§

fn close<'async_trait>( self ) -> Pin<Box<dyn Future<Output = Result<(), Self::ConsumeError>> + 'async_trait>>
where Self: 'async_trait,

Closes this collection. Read more
source§

impl<S: Storage, H> AsyncTruncate for Store<S, H>

§

type Mark = <S as AsyncTruncate>::Mark

Type to denote a truncation “mark”, after which the collection will be truncated.
§

type TruncError = StoreError<<S as Storage>::Error>

Error that can occur during a truncation operation.
source§

fn truncate<'life0, 'life1, 'async_trait>( &'life0 mut self, pos: &'life1 Self::Mark ) -> Pin<Box<dyn Future<Output = Result<(), Self::TruncError>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Truncates this collection after the given mark, such that this collection contains records only upto this “mark”.
source§

impl<S: Default, H> Default for Store<S, H>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<S: Storage, H> Sizable for Store<S, H>

§

type Size = <S as Sizable>::Size

Type to represent the size of this collection in number of bytes.
source§

fn size(&self) -> Self::Size

Returns the size of this collection in butes.

Auto Trait Implementations§

§

impl<S, H> Freeze for Store<S, H>
where S: Freeze,

§

impl<S, H> RefUnwindSafe for Store<S, H>

§

impl<S, H> Send for Store<S, H>
where H: Send, S: Send,

§

impl<S, H> Sync for Store<S, H>
where H: Sync, S: Sync,

§

impl<S, H> Unpin for Store<S, H>
where H: Unpin, S: Unpin,

§

impl<S, H> UnwindSafe for Store<S, H>
where H: UnwindSafe, S: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more