pub struct Glob<E: Storage + Metrics, V: Codec> { /* private fields */ }Expand description
Simple section-based blob storage for values.
Uses buffer::Write for batching writes.
Reads go directly to blobs without any caching (ideal for large values that
shouldn’t pollute a buffer pool cache).
Implementations§
Source§impl<E: Storage + Metrics, V: CodecShared> Glob<E, V>
impl<E: Storage + Metrics, V: CodecShared> Glob<E, V>
Sourcepub async fn init(context: E, cfg: Config<V::Cfg>) -> Result<Self, Error>
pub async fn init(context: E, cfg: Config<V::Cfg>) -> Result<Self, Error>
Initialize blob storage, opening existing section blobs.
Sourcepub async fn append(
&mut self,
section: u64,
value: &V,
) -> Result<(u64, u32), Error>
pub async fn append( &mut self, section: u64, value: &V, ) -> Result<(u64, u32), Error>
Append value to section, returns (offset, size).
The returned offset is the byte offset where the entry was written. The returned size is the total bytes written (compressed_data + crc32). Both should be stored in the index entry for later retrieval.
Sourcepub async fn get(
&self,
section: u64,
offset: u64,
size: u32,
) -> Result<V, Error>
pub async fn get( &self, section: u64, offset: u64, size: u32, ) -> Result<V, Error>
Read value at offset with known size (from index entry).
The offset should be the byte offset returned by append().
Reads directly from blob without any caching.
Sourcepub async fn sync(&self, section: u64) -> Result<(), Error>
pub async fn sync(&self, section: u64) -> Result<(), Error>
Sync section to disk (flushes write buffer).
Sourcepub async fn size(&self, section: u64) -> Result<u64, Error>
pub async fn size(&self, section: u64) -> Result<u64, Error>
Get the current size of a section (including buffered data).
Sourcepub async fn rewind(&mut self, section: u64, size: u64) -> Result<(), Error>
pub async fn rewind(&mut self, section: u64, size: u64) -> Result<(), Error>
Rewind to a specific section and size.
Truncates the section to the given size and removes all sections after it.
Sourcepub async fn rewind_section(
&mut self,
section: u64,
size: u64,
) -> Result<(), Error>
pub async fn rewind_section( &mut self, section: u64, size: u64, ) -> Result<(), Error>
Rewind only the given section to a specific size.
Unlike rewind, this does not affect other sections.
Sourcepub fn oldest_section(&self) -> Option<u64>
pub fn oldest_section(&self) -> Option<u64>
Returns the number of the oldest section.
Sourcepub fn newest_section(&self) -> Option<u64>
pub fn newest_section(&self) -> Option<u64>
Returns the number of the newest section.
Sourcepub fn sections(&self) -> impl Iterator<Item = u64> + '_
pub fn sections(&self) -> impl Iterator<Item = u64> + '_
Returns an iterator over all section numbers.
Auto Trait Implementations§
impl<E, V> Freeze for Glob<E, V>
impl<E, V> !RefUnwindSafe for Glob<E, V>
impl<E, V> Send for Glob<E, V>
impl<E, V> Sync for Glob<E, V>
impl<E, V> Unpin for Glob<E, V>
impl<E, V> !UnwindSafe for Glob<E, V>
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
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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>
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>
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