pub struct WriteBuffer { /* private fields */ }Expand description
Session-scoped write buffer.
Writes are queued via push() and flushed to the store in one transaction
via drain(). The buffer is NOT thread-safe — it is owned by a single agent loop.
Implementations§
Source§impl WriteBuffer
impl WriteBuffer
Sourcepub fn new(capacity: usize) -> Self
pub fn new(capacity: usize) -> Self
Create a new WriteBuffer with the given capacity.
When capacity is reached, push() signals the caller to flush.
Sourcepub fn push(&mut self, write: BufferedWrite) -> bool
pub fn push(&mut self, write: BufferedWrite) -> bool
Queue a write operation.
Returns true if the buffer has reached capacity and should be flushed
before the next push().
Sourcepub fn drain(&mut self) -> Vec<BufferedWrite>
pub fn drain(&mut self) -> Vec<BufferedWrite>
Drain all pending writes, returning them in insertion order.
After this call, the buffer is empty and ready for the next turn.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Auto Trait Implementations§
impl Freeze for WriteBuffer
impl RefUnwindSafe for WriteBuffer
impl Send for WriteBuffer
impl Sync for WriteBuffer
impl Unpin for WriteBuffer
impl UnsafeUnpin for WriteBuffer
impl UnwindSafe for WriteBuffer
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request