Struct de_net::connection::databuf::DataBuf
source · pub(super) struct DataBuf {
data: VecDeque<u8>,
slots: VecDeque<Slot>,
ordinals: AHashMap<PackageId, usize>,
}
Expand description
Data buffer based on a ring-buffer.
The underling data structures are optimized with the assumption that data are inserted and removed in roughly FIFO manner.
Fields§
§data: VecDeque<u8>
§slots: VecDeque<Slot>
§ordinals: AHashMap<PackageId, usize>
Mapping from datagram ID to datagram ordinal. See Slot::ordinal
.
Implementations§
source§impl DataBuf
impl DataBuf
pub(super) fn new() -> Self
sourcepub(super) fn get(&self, id: PackageId, buf: &mut [u8]) -> Option<usize>
pub(super) fn get(&self, id: PackageId, buf: &mut [u8]) -> Option<usize>
Searches for data stored under ID id
, and if found, writes the data
to buf
and returns length of the data.
§Panics
Panics if buf
len is smaller than length of found data.
sourcepub(super) fn remove(&mut self, id: PackageId)
pub(super) fn remove(&mut self, id: PackageId)
Removes data stored with ID id
or does nothing if such data do not
exist.
sourcefn slot_index(&self, id: PackageId) -> Option<usize>
fn slot_index(&self, id: PackageId) -> Option<usize>
Get index (withing slots deque) of the slot with ID id
.
Auto Trait Implementations§
impl Freeze for DataBuf
impl RefUnwindSafe for DataBuf
impl Send for DataBuf
impl Sync for DataBuf
impl Unpin for DataBuf
impl UnwindSafe for DataBuf
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