Struct format_struct::I16
source · #[repr(C)]pub struct I16<E>(/* private fields */);
Expand description
A type that wraps a byte array to be decoded into a i16
.
The generic parameter represents the endianness used to decode the wrapped value. In
case the value is expected to have fixed endianness, either BigEndian
or
LittleEndian
types should be used, otherwise the Endian
type.
Implementations§
source§impl<E> I16<E>
impl<E> I16<E>
sourcepub const fn from_bytes(bytes: [u8; 2]) -> Self
pub const fn from_bytes(bytes: [u8; 2]) -> Self
Converts a byte array into a I16
.
source§impl<E> I16<E>
impl<E> I16<E>
sourcepub const fn slice_as_byte_slice(slice: &[Self]) -> &[u8]
pub const fn slice_as_byte_slice(slice: &[Self]) -> &[u8]
Converts an immutable slice of I16
into an immutable byte slice.
sourcepub fn slice_as_byte_slice_mut(slice: &mut [Self]) -> &mut [u8]
pub fn slice_as_byte_slice_mut(slice: &mut [Self]) -> &mut [u8]
Converts a mutable slice of I16
into a mutable byte slice.
sourcepub const fn uninit_slice_as_byte_slice(
slice: &[MaybeUninit<Self>]
) -> &[MaybeUninit<u8>]
pub const fn uninit_slice_as_byte_slice( slice: &[MaybeUninit<Self>] ) -> &[MaybeUninit<u8>]
Converts an immutable slice of MaybeUninit<I16>
into an immutable slice of MaybeUninit<u8>
..
sourcepub fn uninit_slice_as_byte_slice_mut(
slice: &mut [MaybeUninit<Self>]
) -> &mut [MaybeUninit<u8>]
pub fn uninit_slice_as_byte_slice_mut( slice: &mut [MaybeUninit<Self>] ) -> &mut [MaybeUninit<u8>]
Converts a mutable slice of MaybeUninit<I16>
into a mutable slice of MaybeUninit<u8>
.
source§impl I16<Endian>
impl I16<Endian>
sourcepub const fn new_with_endian(value: i16, endian: Endian) -> Self
pub const fn new_with_endian(value: i16, endian: Endian) -> Self
Constructs a I16
wrapper type from a i16
value using the specified endianness.
sourcepub const fn get_with_endian(self, endian: Endian) -> i16
pub const fn get_with_endian(self, endian: Endian) -> i16
Extracts a i16
value from a I16
wrapper using the specified endianness.
Trait Implementations§
source§impl<E> FromByteSlice for I16<E>
impl<E> FromByteSlice for I16<E>
source§fn from_byte_slice(s: &[u8]) -> Result<&Self, InvalidSizeError>
fn from_byte_slice(s: &[u8]) -> Result<&Self, InvalidSizeError>
Self
reference. Read moresource§fn from_byte_slice_mut(s: &mut [u8]) -> Result<&mut Self, InvalidSizeError>
fn from_byte_slice_mut(s: &mut [u8]) -> Result<&mut Self, InvalidSizeError>
Self
reference. Read moresource§fn slice_from_byte_slice(s: &[u8]) -> Result<&[Self], InvalidSizeError>
fn slice_from_byte_slice(s: &[u8]) -> Result<&[Self], InvalidSizeError>
Self
. Read moresource§fn slice_from_byte_slice_mut(
s: &mut [u8]
) -> Result<&mut [Self], InvalidSizeError>
fn slice_from_byte_slice_mut( s: &mut [u8] ) -> Result<&mut [Self], InvalidSizeError>
Self
. Read more