pub struct Archive<T: Translator, B: Blob, E: Storage<B>> { /* private fields */ }
Expand description
Implementation of Archive
storage.
Implementations§
Source§impl<T: Translator, B: Blob, E: Storage<B>> Archive<T, B, E>
impl<T: Translator, B: Blob, E: Storage<B>> Archive<T, B, E>
Sourcepub async fn init(journal: Journal<B, E>, cfg: Config<T>) -> Result<Self, Error>
pub async fn init(journal: Journal<B, E>, cfg: Config<T>) -> Result<Self, Error>
Initialize a new Archive
instance.
The in-memory index for Archive
is populated during this call
by replaying the journal.
Sourcepub async fn put(
&mut self,
index: u64,
key: &[u8],
data: Bytes,
) -> Result<(), Error>
pub async fn put( &mut self, index: u64, key: &[u8], data: Bytes, ) -> Result<(), Error>
Store an item in Archive
. Both indices and keys are assumed to both be globally unique.
If the index already exists, an error is returned. If the same key is stored multiple times at different indices (not recommended), any value associated with the key may be returned.
Sourcepub async fn get(
&self,
identifier: Identifier<'_>,
) -> Result<Option<Bytes>, Error>
pub async fn get( &self, identifier: Identifier<'_>, ) -> Result<Option<Bytes>, Error>
Retrieve an item from Archive
.
Sourcepub async fn has(&self, identifier: Identifier<'_>) -> Result<bool, Error>
pub async fn has(&self, identifier: Identifier<'_>) -> Result<bool, Error>
Check if an item exists in the Archive
.
Sourcepub async fn prune(&mut self, min: u64) -> Result<(), Error>
pub async fn prune(&mut self, min: u64) -> Result<(), Error>
Prune Archive
to the provided min
(masked by the configured
section mask).
If this is called with a min lower than the last pruned, nothing will happen.
Sourcepub async fn sync(&mut self) -> Result<(), Error>
pub async fn sync(&mut self) -> Result<(), Error>
Forcibly sync all pending writes across all Journals
.
Auto Trait Implementations§
impl<T, B, E> Freeze for Archive<T, B, E>
impl<T, B, E> RefUnwindSafe for Archive<T, B, E>
impl<T, B, E> Send for Archive<T, B, E>where
T: Send,
impl<T, B, E> Sync for Archive<T, B, E>where
T: Sync,
impl<T, B, E> Unpin for Archive<T, B, E>
impl<T, B, E> UnwindSafe for Archive<T, B, E>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more