pub struct BufferPolicy { /* private fields */ }Expand description
Buffering contract for a stream: a bounded capacity plus an overflow rule.
A policy is always bounded with a capacity of at least one; the constructors reject a zero capacity. The overflow rule decides what happens when the buffer is full.
§Examples
use sim_lib_stream_core::{BufferOverflowPolicy, BufferPolicy};
let policy = BufferPolicy::bounded(8).expect("capacity is nonzero");
assert_eq!(policy.capacity(), 8);
assert_eq!(policy.overflow(), BufferOverflowPolicy::DropNewest);
assert!(BufferPolicy::bounded(0).is_err());Implementations§
Source§impl BufferPolicy
impl BufferPolicy
Sourcepub fn bounded(capacity: usize) -> Result<Self>
pub fn bounded(capacity: usize) -> Result<Self>
Builds a bounded policy of capacity with the default
BufferOverflowPolicy::DropNewest overflow rule.
Returns an error if capacity is zero.
Sourcepub fn bounded_with_overflow(
capacity: usize,
overflow: BufferOverflowPolicy,
) -> Result<Self>
pub fn bounded_with_overflow( capacity: usize, overflow: BufferOverflowPolicy, ) -> Result<Self>
Builds a bounded policy of capacity with an explicit overflow rule.
Returns an error if capacity is zero.
Sourcepub fn overflow(&self) -> BufferOverflowPolicy
pub fn overflow(&self) -> BufferOverflowPolicy
Returns the overflow rule.
Sourcepub fn symbol(&self) -> Symbol
pub fn symbol(&self) -> Symbol
Returns the stream/buffer/bounded-<capacity> symbol for this policy.
Trait Implementations§
Source§impl Clone for BufferPolicy
impl Clone for BufferPolicy
Source§fn clone(&self) -> BufferPolicy
fn clone(&self) -> BufferPolicy
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for BufferPolicy
impl Debug for BufferPolicy
impl Eq for BufferPolicy
Source§impl PartialEq for BufferPolicy
impl PartialEq for BufferPolicy
Source§fn eq(&self, other: &BufferPolicy) -> bool
fn eq(&self, other: &BufferPolicy) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for BufferPolicy
Auto Trait Implementations§
impl Freeze for BufferPolicy
impl RefUnwindSafe for BufferPolicy
impl Send for BufferPolicy
impl Sync for BufferPolicy
impl Unpin for BufferPolicy
impl UnsafeUnpin for BufferPolicy
impl UnwindSafe for BufferPolicy
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