Trait UnalignedWrite

Source
pub trait UnalignedWrite {
Show 15 methods // Required methods unsafe fn write_u8_at(self, byte_offset: usize, value: u8); unsafe fn write_u16_at(self, byte_offset: usize, value: u16); unsafe fn write_u32_at(self, byte_offset: usize, value: u32); unsafe fn write_u64_at(self, byte_offset: usize, value: u64); unsafe fn write_u128_at(self, byte_offset: usize, value: u128); unsafe fn write_usize_at(self, byte_offset: usize, value: usize); unsafe fn write_i8_at(self, byte_offset: usize, value: i8); unsafe fn write_i16_at(self, byte_offset: usize, value: i16); unsafe fn write_i32_at(self, byte_offset: usize, value: i32); unsafe fn write_i64_at(self, byte_offset: usize, value: i64); unsafe fn write_i128_at(self, byte_offset: usize, value: i128); unsafe fn write_isize_at(self, byte_offset: usize, value: isize); unsafe fn write_f32_at(self, byte_offset: usize, value: f32); unsafe fn write_f64_at(self, byte_offset: usize, value: f64); unsafe fn write_bool_at(self, byte_offset: usize, value: bool);
}
Expand description

Trait providing convenient unaligned write operations for mutable pointer types.

Required Methods§

Source

unsafe fn write_u8_at(self, byte_offset: usize, value: u8)

Writes a u8 value to the pointer at the given byte offset.

§Safety
  • The pointer plus byte offset must be valid for writing 1 byte
  • The caller must ensure the pointer remains valid for the duration of the write
  • The memory location must be mutable
Source

unsafe fn write_u16_at(self, byte_offset: usize, value: u16)

Writes a u16 value to the pointer at the given byte offset.

§Safety
  • The pointer plus byte offset must be valid for writing 2 bytes
  • The caller must ensure the pointer remains valid for the duration of the write
  • The memory location must be mutable
  • No alignment requirements - this performs unaligned writes
Source

unsafe fn write_u32_at(self, byte_offset: usize, value: u32)

Writes a u32 value to the pointer at the given byte offset.

§Safety
  • The pointer plus byte offset must be valid for writing 4 bytes
  • The caller must ensure the pointer remains valid for the duration of the write
  • The memory location must be mutable
  • No alignment requirements - this performs unaligned writes
Source

unsafe fn write_u64_at(self, byte_offset: usize, value: u64)

Writes a u64 value to the pointer at the given byte offset.

§Safety
  • The pointer plus byte offset must be valid for writing 8 bytes
  • The caller must ensure the pointer remains valid for the duration of the write
  • The memory location must be mutable
  • No alignment requirements - this performs unaligned writes
Source

unsafe fn write_u128_at(self, byte_offset: usize, value: u128)

Writes a u128 value to the pointer at the given byte offset.

§Safety
  • The pointer plus byte offset must be valid for writing 16 bytes
  • The caller must ensure the pointer remains valid for the duration of the write
  • The memory location must be mutable
  • No alignment requirements - this performs unaligned writes
Source

unsafe fn write_usize_at(self, byte_offset: usize, value: usize)

Writes a usize value to the pointer at the given byte offset.

§Safety
  • The pointer plus byte offset must be valid for writing size_of::<usize>() bytes
  • The caller must ensure the pointer remains valid for the duration of the write
  • The memory location must be mutable
  • No alignment requirements - this performs unaligned writes
Source

unsafe fn write_i8_at(self, byte_offset: usize, value: i8)

Writes an i8 value to the pointer at the given byte offset.

§Safety
  • The pointer plus byte offset must be valid for writing 1 byte
  • The caller must ensure the pointer remains valid for the duration of the write
  • The memory location must be mutable
Source

unsafe fn write_i16_at(self, byte_offset: usize, value: i16)

Writes an i16 value to the pointer at the given byte offset.

§Safety
  • The pointer plus byte offset must be valid for writing 2 bytes
  • The caller must ensure the pointer remains valid for the duration of the write
  • The memory location must be mutable
  • No alignment requirements - this performs unaligned writes
Source

unsafe fn write_i32_at(self, byte_offset: usize, value: i32)

Writes an i32 value to the pointer at the given byte offset.

§Safety
  • The pointer plus byte offset must be valid for writing 4 bytes
  • The caller must ensure the pointer remains valid for the duration of the write
  • The memory location must be mutable
  • No alignment requirements - this performs unaligned writes
Source

unsafe fn write_i64_at(self, byte_offset: usize, value: i64)

Writes an i64 value to the pointer at the given byte offset.

§Safety
  • The pointer plus byte offset must be valid for writing 8 bytes
  • The caller must ensure the pointer remains valid for the duration of the write
  • The memory location must be mutable
  • No alignment requirements - this performs unaligned writes
Source

unsafe fn write_i128_at(self, byte_offset: usize, value: i128)

Writes an i128 value to the pointer at the given byte offset.

§Safety
  • The pointer plus byte offset must be valid for writing 16 bytes
  • The caller must ensure the pointer remains valid for the duration of the write
  • The memory location must be mutable
  • No alignment requirements - this performs unaligned writes
Source

unsafe fn write_isize_at(self, byte_offset: usize, value: isize)

Writes an isize value to the pointer at the given byte offset.

§Safety
  • The pointer plus byte offset must be valid for writing size_of::<isize>() bytes
  • The caller must ensure the pointer remains valid for the duration of the write
  • The memory location must be mutable
  • No alignment requirements - this performs unaligned writes
Source

unsafe fn write_f32_at(self, byte_offset: usize, value: f32)

Writes an f32 value to the pointer at the given byte offset.

§Safety
  • The pointer plus byte offset must be valid for writing 4 bytes
  • The caller must ensure the pointer remains valid for the duration of the write
  • The memory location must be mutable
  • No alignment requirements - this performs unaligned writes
Source

unsafe fn write_f64_at(self, byte_offset: usize, value: f64)

Writes an f64 value to the pointer at the given byte offset.

§Safety
  • The pointer plus byte offset must be valid for writing 8 bytes
  • The caller must ensure the pointer remains valid for the duration of the write
  • The memory location must be mutable
  • No alignment requirements - this performs unaligned writes
Source

unsafe fn write_bool_at(self, byte_offset: usize, value: bool)

Writes a bool value to the pointer at the given byte offset.

§Safety
  • The pointer plus byte offset must be valid for writing 1 byte
  • The caller must ensure the pointer remains valid for the duration of the write
  • The memory location must be mutable

Implementations on Foreign Types§

Source§

impl<T> UnalignedWrite for *mut T

Source§

unsafe fn write_u8_at(self, byte_offset: usize, value: u8)

Source§

unsafe fn write_u16_at(self, byte_offset: usize, value: u16)

Source§

unsafe fn write_u32_at(self, byte_offset: usize, value: u32)

Source§

unsafe fn write_u64_at(self, byte_offset: usize, value: u64)

Source§

unsafe fn write_u128_at(self, byte_offset: usize, value: u128)

Source§

unsafe fn write_usize_at(self, byte_offset: usize, value: usize)

Source§

unsafe fn write_i8_at(self, byte_offset: usize, value: i8)

Source§

unsafe fn write_i16_at(self, byte_offset: usize, value: i16)

Source§

unsafe fn write_i32_at(self, byte_offset: usize, value: i32)

Source§

unsafe fn write_i64_at(self, byte_offset: usize, value: i64)

Source§

unsafe fn write_i128_at(self, byte_offset: usize, value: i128)

Source§

unsafe fn write_isize_at(self, byte_offset: usize, value: isize)

Source§

unsafe fn write_f32_at(self, byte_offset: usize, value: f32)

Source§

unsafe fn write_f64_at(self, byte_offset: usize, value: f64)

Source§

unsafe fn write_bool_at(self, byte_offset: usize, value: bool)

Implementors§