pub struct BatchAccumulator { /* private fields */ }Expand description
Accumulates CRDT operations for batched transmission
Implementations§
Source§impl BatchAccumulator
impl BatchAccumulator
Sourcepub fn new(config: BatchConfig) -> Self
pub fn new(config: BatchConfig) -> Self
Create a new accumulator with the given config
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Create with default config
Sourcepub fn add(&mut self, op: CrdtOperation, current_time_ms: u64) -> bool
pub fn add(&mut self, op: CrdtOperation, current_time_ms: u64) -> bool
Add an operation to the batch
Returns true if the operation was added, false if batch is full
Sourcepub fn should_flush(&self, current_time_ms: u64) -> bool
pub fn should_flush(&self, current_time_ms: u64) -> bool
Check if the batch should be flushed
Sourcepub fn flush(&mut self, current_time_ms: u64) -> Option<OperationBatch>
pub fn flush(&mut self, current_time_ms: u64) -> Option<OperationBatch>
Flush pending operations into a batch
Sourcepub fn force_flush(&mut self, current_time_ms: u64) -> Option<OperationBatch>
pub fn force_flush(&mut self, current_time_ms: u64) -> Option<OperationBatch>
Force flush regardless of timing constraints
Sourcepub fn pending_count(&self) -> usize
pub fn pending_count(&self) -> usize
Get number of pending operations
Sourcepub fn accumulated_bytes(&self) -> usize
pub fn accumulated_bytes(&self) -> usize
Get accumulated bytes
Sourcepub fn has_pending(&self) -> bool
pub fn has_pending(&self) -> bool
Check if there are pending operations
Sourcepub fn config(&self) -> &BatchConfig
pub fn config(&self) -> &BatchConfig
Get the config
Sourcepub fn set_config(&mut self, config: BatchConfig)
pub fn set_config(&mut self, config: BatchConfig)
Update the config
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BatchAccumulator
impl RefUnwindSafe for BatchAccumulator
impl Send for BatchAccumulator
impl Sync for BatchAccumulator
impl Unpin for BatchAccumulator
impl UnwindSafe for BatchAccumulator
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