pub struct PortBuffer { /* private fields */ }Expand description
A buffer that sits between an output port and an input port.
Implementations§
Source§impl PortBuffer
impl PortBuffer
Sourcepub fn new(strategy: BufferStrategy, label: &str) -> Self
pub fn new(strategy: BufferStrategy, label: &str) -> Self
Create a new port buffer with the given strategy.
Sourcepub fn push(&mut self, token: FrameToken) -> bool
pub fn push(&mut self, token: FrameToken) -> bool
Push a frame token into the buffer.
Returns true if the frame was accepted, false if it was dropped
due to overflow (for bounded strategies).
Sourcepub fn pop(&mut self) -> Option<FrameToken>
pub fn pop(&mut self) -> Option<FrameToken>
Pop the next frame token from the buffer.
Sourcepub fn peek(&self) -> Option<&FrameToken>
pub fn peek(&self) -> Option<&FrameToken>
Peek at the next frame token without removing it.
Sourcepub fn status(&self) -> BufferStatus
pub fn status(&self) -> BufferStatus
Get the current buffer status.
Sourcepub fn strategy(&self) -> BufferStrategy
pub fn strategy(&self) -> BufferStrategy
Get the buffering strategy.
Sourcepub fn max_capacity(&self) -> usize
pub fn max_capacity(&self) -> usize
Get the maximum capacity (0 for unbounded).
Sourcepub fn total_pushed(&self) -> u64
pub fn total_pushed(&self) -> u64
Get the total number of frames pushed.
Sourcepub fn total_popped(&self) -> u64
pub fn total_popped(&self) -> u64
Get the total number of frames popped.
Sourcepub fn drain_all(&mut self) -> Vec<FrameToken>
pub fn drain_all(&mut self) -> Vec<FrameToken>
Drain all frames from the buffer as a vector.
Sourcepub fn fill_ratio(&self) -> f64
pub fn fill_ratio(&self) -> f64
Get fill ratio (0.0 to 1.0). Returns 0.0 for unbounded buffers.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PortBuffer
impl RefUnwindSafe for PortBuffer
impl Send for PortBuffer
impl Sync for PortBuffer
impl Unpin for PortBuffer
impl UnsafeUnpin for PortBuffer
impl UnwindSafe for PortBuffer
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> 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 more