pub struct Buffer<T> { /* private fields */ }Expand description
A buffer of copy values with a max size of u32::MAX.
Make sure to interreact with the buffer through a session
when writing and reading from the buffer:
let mut buffer = Buffer::empty();
let mut session = buffer.new_session();
let key = session.next_slice();
session.extend([1, 2, 3]);
assert_eq!(buffer.get(key), &[1, 2, 3]);and use the SliceIndex to access the buffer.
Implementations§
Source§impl<T: Copy> Buffer<T>
impl<T: Copy> Buffer<T>
Sourcepub fn new_session(&mut self) -> Session<'_, T>
pub fn new_session(&mut self) -> Session<'_, T>
Create a new session that can be converted into a session key, with access to the underlying storage written to by the session.
pub fn get(&self, index: SliceIndex) -> &[T]
pub fn get_mut(&mut self, index: SliceIndex) -> &mut [T]
Sourcepub fn tail_drain(&mut self, size: u32)
pub fn tail_drain(&mut self, size: u32)
Drain values from the end of the buffer, regardless of which key it belongs to.
This will update the last key in the buffer
§Panics
Panics if there are no keys in the buffer
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Buffer<T>
impl<T> RefUnwindSafe for Buffer<T>where
T: RefUnwindSafe,
impl<T> Send for Buffer<T>where
T: Send,
impl<T> Sync for Buffer<T>where
T: Sync,
impl<T> Unpin for Buffer<T>where
T: Unpin,
impl<T> UnsafeUnpin for Buffer<T>
impl<T> UnwindSafe for Buffer<T>where
T: UnwindSafe,
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