Append

Struct Append 

Source
pub struct Append<B: Blob> { /* private fields */ }
Expand description

A Blob wrapper that supports write-cached appending of data, with checksums for data integrity and buffer pool managed caching.

Implementations§

Source§

impl<B: Blob> Append<B>

Source

pub async fn new( blob: B, original_blob_size: u64, capacity: usize, pool_ref: PoolRef, ) -> Result<Self, Error>

Create a new Append wrapper of the provided blob that is known to have blob_size underlying physical bytes, using the provided pool for read caching, and a write buffer with capacity capacity. Rewinds the blob if necessary to ensure it only contains checksum-validated data.

Source

pub async fn new_immutable( blob: B, blob_size: u64, capacity: usize, pool_ref: PoolRef, ) -> Result<Self, Error>

Return a new Append wrapper of the provided blob that is known to have blob_size underlying physical bytes, using the provided pool for read caching. The wrapper is for read-only data, and any append attempts will return error. The provided capacity is used only if the blob is later turned into a mutable one. Immutable blobs are assumed consistent on disk, so any CRC verification failure results in an error without any recovery attempt.

Source

pub async fn is_immutable(&self) -> bool

Returns true if this blob is in the immutable state.

Source

pub async fn to_immutable(&self) -> Result<(), Error>

Convert this blob to the immutable state if it’s not already in it.

If there is unwritten data in the buffer, it will be flushed and synced before returning.

Source

pub async fn to_mutable(&self)

Convert this blob to the mutable state if it’s not already in it.

Source

pub async fn append(&self, buf: &[u8]) -> Result<(), Error>

Append all bytes in buf to the tip of the blob.

§Errors
  • Error::ImmutableBlob - The blob is in the immutable state.
Source

pub async fn size(&self) -> u64

Returns the logical size of the blob. This accounts for both written and buffered data.

Source

pub async fn read_up_to( &self, buf: impl Into<StableBuf> + Send, logical_offset: u64, ) -> Result<(StableBuf, usize), Error>

Reads up to buf.len() bytes starting at logical_offset, but only as many as are available.

This is useful for reading variable-length prefixes (like varints) where you want to read up to a maximum number of bytes but the actual data might be shorter.

Returns the number of bytes actually read into the buffer. Returns an error if no bytes are available at the given offset.

Source

pub async fn read_into( &self, buf: &mut [u8], logical_offset: u64, ) -> Result<(), Error>

Reads bytes starting at logical_offset into buf.

This method allows reading directly into a mutable slice without taking ownership of the buffer or requiring a specific buffer type.

Source

pub async fn replay( &self, buffer_size: NonZeroUsize, ) -> Result<Replay<B>, Error>

Flushes any buffered data, then returns a Replay for the underlying blob.

The returned replay can be used to sequentially read all pages from the blob while ensuring all data passes integrity verification. CRCs are validated but not included in the output.

Trait Implementations§

Source§

impl<B: Blob> Blob for Append<B>

Source§

async fn write_at( &self, _buf: impl Into<StableBuf> + Send, _offset: u64, ) -> Result<(), Error>

This Blob trait method is unimplemented by Append and unconditionally panics.

Source§

async fn resize(&self, size: u64) -> Result<(), Error>

Resize the blob to the provided logical size.

This truncates the blob to contain only size logical bytes. The physical blob size will be adjusted to include the necessary CRC records for the remaining pages.

§Warning
  • Concurrent mutable operations (append, resize) are not supported and will cause data loss.
  • Concurrent readers which try to read past the new size during the resize may error.
  • The resize is not guaranteed durable until the next sync.
Source§

async fn read_at( &self, buf: impl Into<StableBuf> + Send, logical_offset: u64, ) -> Result<StableBuf, Error>

Read from the blob at the given offset. Read more
Source§

async fn sync(&self) -> Result<(), Error>

Ensure all pending data is durably persisted.
Source§

impl<B: Clone + Blob> Clone for Append<B>

Source§

fn clone(&self) -> Append<B>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<B> Freeze for Append<B>

§

impl<B> !RefUnwindSafe for Append<B>

§

impl<B> Send for Append<B>

§

impl<B> Sync for Append<B>

§

impl<B> Unpin for Append<B>

§

impl<B> !UnwindSafe for Append<B>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
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.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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>,

Source§

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,