Skip to main content

FieldMut

Struct FieldMut 

Source
pub struct FieldMut<'a> { /* private fields */ }
Expand description

Mutable typed view over a field-sized byte slice.

Produced by split_fields_mut (generated by zero_copy_layout!). Provides typed mutation without holding &mut to the whole struct.

Implementations§

Source§

impl<'a> FieldMut<'a>

Source

pub fn new(data: &'a mut [u8]) -> Self

Create a mutable field reference from a byte slice.

Source

pub fn len(&self) -> usize

The byte length of this field.

Source

pub fn is_empty(&self) -> bool

Whether the field is zero-length.

Source

pub fn as_bytes(&self) -> &[u8]

Read the raw bytes.

Source

pub fn as_bytes_mut(&mut self) -> &mut [u8]

Get the raw mutable bytes.

Source

pub fn read_address(&self) -> Address

Read as an Address (32-byte public key).

Source

pub fn as_address(&self) -> &Address

Borrow the field bytes as an &Address reference.

Source

pub fn write_address(&mut self, addr: &Address)

Write an Address (32-byte public key).

Source

pub fn write_u64(&mut self, v: u64)

Write a u64 (LE).

Source

pub fn write_u32(&mut self, v: u32)

Write a u32 (LE).

Source

pub fn write_u16(&mut self, v: u16)

Write a u16 (LE).

Source

pub fn write_u8(&mut self, v: u8)

Write a u8.

Source

pub fn write_bool(&mut self, v: bool)

Write a bool.

Source

pub fn write_i64(&mut self, v: i64)

Write an i64 (LE).

Source

pub fn write_i32(&mut self, v: i32)

Write an i32 (LE).

Source

pub fn write_i16(&mut self, v: i16)

Write an i16 (LE).

Source

pub fn write_i8(&mut self, v: i8)

Write an i8.

Source

pub fn write_u128(&mut self, v: u128)

Write a u128 (LE).

Source

pub fn write_i128(&mut self, v: i128)

Write an i128 (LE).

Source

pub fn read_u64(&self) -> u64

Read a u64 (LE).

Source

pub fn read_u32(&self) -> u32

Read a u32 (LE).

Source

pub fn read_u16(&self) -> u16

Read a u16 (LE).

Source

pub fn read_u8(&self) -> u8

Read a u8.

Source

pub fn read_bool(&self) -> bool

Read a bool.

Source

pub fn read_i64(&self) -> i64

Read an i64 (LE).

Source

pub fn read_i32(&self) -> i32

Read an i32 (LE).

Source

pub fn read_i16(&self) -> i16

Read an i16 (LE).

Source

pub fn read_i8(&self) -> i8

Read an i8.

Source

pub fn read_u128(&self) -> u128

Read a u128 (LE).

Source

pub fn read_i128(&self) -> i128

Read an i128 (LE).

Source

pub fn copy_from(&mut self, src: &[u8])

Copy from a byte slice (e.g., an Address).

Auto Trait Implementations§

§

impl<'a> Freeze for FieldMut<'a>

§

impl<'a> RefUnwindSafe for FieldMut<'a>

§

impl<'a> Send for FieldMut<'a>

§

impl<'a> Sync for FieldMut<'a>

§

impl<'a> Unpin for FieldMut<'a>

§

impl<'a> UnsafeUnpin for FieldMut<'a>

§

impl<'a> !UnwindSafe for FieldMut<'a>

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> 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, 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.