pub struct SafeBuffer<T> { /* private fields */ }Expand description
Safe buffer with automatic bounds checking and buffer overflow protection
Implementations§
Source§impl<T: Clone> SafeBuffer<T>
impl<T: Clone> SafeBuffer<T>
Sourcepub fn new(capacity: usize, default_value: T) -> Self
pub fn new(capacity: usize, default_value: T) -> Self
Create a new safe buffer with fixed capacity
Sourcepub fn write(&mut self, index: usize, value: T) -> UtilsResult<()>
pub fn write(&mut self, index: usize, value: T) -> UtilsResult<()>
Write to buffer with bounds checking
Sourcepub fn read(&self, index: usize) -> UtilsResult<&T>
pub fn read(&self, index: usize) -> UtilsResult<&T>
Read from buffer with bounds checking
Sourcepub fn append(&mut self, value: T) -> UtilsResult<()>
pub fn append(&mut self, value: T) -> UtilsResult<()>
Append to buffer
Sourcepub unsafe fn disable_overflow_protection(&mut self)
pub unsafe fn disable_overflow_protection(&mut self)
Disable overflow protection (unsafe)
§Safety
This function disables the buffer’s overflow protection mechanism, allowing operations that could potentially lead to buffer overflows or memory corruption. The caller must ensure that all subsequent operations on the buffer are within proper bounds.
Trait Implementations§
Source§impl<T: Clone> Clone for SafeBuffer<T>
impl<T: Clone> Clone for SafeBuffer<T>
Source§fn clone(&self) -> SafeBuffer<T>
fn clone(&self) -> SafeBuffer<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<T> Freeze for SafeBuffer<T>
impl<T> RefUnwindSafe for SafeBuffer<T>where
T: RefUnwindSafe,
impl<T> Send for SafeBuffer<T>where
T: Send,
impl<T> Sync for SafeBuffer<T>where
T: Sync,
impl<T> Unpin for SafeBuffer<T>where
T: Unpin,
impl<T> UnwindSafe for SafeBuffer<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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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