pub struct PortBuffer {
pub node_id: u64,
pub port: u32,
pub buffer: VecDeque<DataPacket>,
pub max_size: usize,
}Expand description
A bounded FIFO queue of DataPackets associated with one (node, port) pair.
Fields§
§node_id: u64Node ID that owns this buffer.
port: u32Port index this buffer serves.
buffer: VecDeque<DataPacket>Queued packets, oldest at the front.
max_size: usizeMaximum number of packets this buffer may hold.
Implementations§
Source§impl PortBuffer
impl PortBuffer
Sourcepub fn new(node_id: u64, port: u32, max_size: usize) -> Self
pub fn new(node_id: u64, port: u32, max_size: usize) -> Self
Creates a new, empty port buffer with the given capacity.
Sourcepub fn push(&mut self, packet: DataPacket) -> bool
pub fn push(&mut self, packet: DataPacket) -> bool
Enqueues packet if there is room. Returns true on success.
Sourcepub fn pop(&mut self) -> Option<DataPacket>
pub fn pop(&mut self) -> Option<DataPacket>
Removes and returns the oldest packet, or None if empty.
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