Skip to main content

AlignedBuffer

Struct AlignedBuffer 

Source
pub struct AlignedBuffer<const N: usize> { /* private fields */ }
Expand description

Cache-line aligned buffer for optimal CPU cache performance.

The buffer is aligned to 64 bytes (typical cache line size) to prevent false sharing and ensure optimal memory access patterns.

§Type Parameters

  • N - Buffer size in bytes

Implementations§

Source§

impl<const N: usize> AlignedBuffer<N>

Source

pub const fn new() -> Self

Creates a new zeroed aligned buffer.

Source

pub const fn zeroed() -> Self

Creates a new zeroed aligned buffer (alias for new).

Source

pub const fn capacity(&self) -> usize

Returns the capacity of the buffer in bytes.

Trait Implementations§

Source§

impl<const N: usize> AsMut<[u8]> for AlignedBuffer<N>

Source§

fn as_mut(&mut self) -> &mut [u8]

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<const N: usize> AsRef<[u8]> for AlignedBuffer<N>

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<const N: usize> Clone for AlignedBuffer<N>

Source§

fn clone(&self) -> AlignedBuffer<N>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<const N: usize> Debug for AlignedBuffer<N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<const N: usize> Default for AlignedBuffer<N>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<const N: usize> ReadBuffer for AlignedBuffer<N>

Source§

fn as_slice(&self) -> &[u8]

Returns the buffer as a byte slice.
Source§

fn len(&self) -> usize

Returns the length of the buffer in bytes.
Source§

fn is_empty(&self) -> bool

Returns true if the buffer is empty.
Source§

fn get_u8(&self, offset: usize) -> u8

Reads a u8 at the given offset. Read more
Source§

fn get_i8(&self, offset: usize) -> i8

Reads an i8 at the given offset. Read more
Source§

fn get_u16_le(&self, offset: usize) -> u16

Reads a u16 in little-endian at the given offset. Read more
Source§

fn get_i16_le(&self, offset: usize) -> i16

Reads an i16 in little-endian at the given offset. Read more
Source§

fn get_u32_le(&self, offset: usize) -> u32

Reads a u32 in little-endian at the given offset. Read more
Source§

fn get_i32_le(&self, offset: usize) -> i32

Reads an i32 in little-endian at the given offset. Read more
Source§

fn get_u64_le(&self, offset: usize) -> u64

Reads a u64 in little-endian at the given offset. Read more
Source§

fn get_i64_le(&self, offset: usize) -> i64

Reads an i64 in little-endian at the given offset. Read more
Source§

fn get_f32_le(&self, offset: usize) -> f32

Reads an f32 in little-endian at the given offset. Read more
Source§

fn get_f64_le(&self, offset: usize) -> f64

Reads an f64 in little-endian at the given offset. Read more
Source§

fn get_bytes(&self, offset: usize, len: usize) -> &[u8]

Returns a slice of bytes at the given offset and length. Read more
Source§

fn get_str(&self, offset: usize, len: usize) -> &str

Reads a fixed-length character array as a string slice. Trims null bytes from the end. Read more
Source§

impl<const N: usize> WriteBuffer for AlignedBuffer<N>

Source§

fn as_mut_slice(&mut self) -> &mut [u8]

Returns the buffer as a mutable byte slice.
Source§

fn put_u8(&mut self, offset: usize, value: u8)

Writes a u8 at the given offset. Read more
Source§

fn put_i8(&mut self, offset: usize, value: i8)

Writes an i8 at the given offset. Read more
Source§

fn put_u16_le(&mut self, offset: usize, value: u16)

Writes a u16 in little-endian at the given offset. Read more
Source§

fn put_i16_le(&mut self, offset: usize, value: i16)

Writes an i16 in little-endian at the given offset. Read more
Source§

fn put_u32_le(&mut self, offset: usize, value: u32)

Writes a u32 in little-endian at the given offset. Read more
Source§

fn put_i32_le(&mut self, offset: usize, value: i32)

Writes an i32 in little-endian at the given offset. Read more
Source§

fn put_u64_le(&mut self, offset: usize, value: u64)

Writes a u64 in little-endian at the given offset. Read more
Source§

fn put_i64_le(&mut self, offset: usize, value: i64)

Writes an i64 in little-endian at the given offset. Read more
Source§

fn put_f32_le(&mut self, offset: usize, value: f32)

Writes an f32 in little-endian at the given offset. Read more
Source§

fn put_f64_le(&mut self, offset: usize, value: f64)

Writes an f64 in little-endian at the given offset. Read more
Source§

fn put_bytes(&mut self, offset: usize, src: &[u8])

Writes a byte slice at the given offset. Read more
Source§

fn put_str(&mut self, offset: usize, value: &str, max_len: usize)

Writes a string to a fixed-length field, padding with nulls. Read more
Source§

fn zero(&mut self, offset: usize, len: usize)

Fills a range with zeros. Read more

Auto Trait Implementations§

§

impl<const N: usize> Freeze for AlignedBuffer<N>

§

impl<const N: usize> RefUnwindSafe for AlignedBuffer<N>

§

impl<const N: usize> Send for AlignedBuffer<N>

§

impl<const N: usize> Sync for AlignedBuffer<N>

§

impl<const N: usize> Unpin for AlignedBuffer<N>

§

impl<const N: usize> UnwindSafe for AlignedBuffer<N>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.