U24

Struct U24 

Source
pub struct U24(/* private fields */);
Expand description

Represents a 24-bit unsigned integer (U24), supporting SV2 serialization and deserialization. Only first 3 bytes of a u32 is considered to get the SV2 value, and rest are ignored (in little endian).

Trait Implementations§

Source§

impl Clone for U24

Source§

fn clone(&self) -> U24

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 Debug for U24

Source§

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

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

impl<'a> Decodable<'a> for U24

Source§

fn get_structure(_: &[u8]) -> Result<Vec<FieldMarker>, Error>

Defines the expected structure of a type based on binary data. Read more
Source§

fn from_decoded_fields(data: Vec<DecodableField<'a>>) -> Result<Self, Error>

Constructs the type from a vector of decoded fields. Read more
Source§

fn from_bytes(data: &'a mut [u8]) -> Result<Self, Error>

Decodes the type from raw bytes. Read more
Source§

impl Fixed for U24

Source§

const SIZE: usize = 3usize

the constant SIZE, represents the fixed number of bytes needed to encode or decode the type.
Source§

impl From<U24> for EncodableField<'_>

Source§

fn from(v: U24) -> Self

Converts to this type from the input type.
Source§

impl From<U24> for FieldMarker

Source§

fn from(_: U24) -> Self

Converts to this type from the input type.
Source§

impl From<U24> for u32

Source§

fn from(v: U24) -> Self

Converts to this type from the input type.
Source§

impl GetMarker for U24

Source§

fn get_marker() -> FieldMarker

Defines the structure of a type for decoding purposes, supporting both primitive and structured types. It helps getting a marker for a type.
Source§

impl PartialEq for U24

Source§

fn eq(&self, other: &U24) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> Sv2DataType<'a> for U24

Source§

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

Constructs an instance from a mutable byte slice without verifying size constraints.
Source§

fn from_vec_(data: Vec<u8>) -> Result<Self, Error>

Constructs an instance from a vector, checking for the correct size.
Source§

fn from_vec_unchecked(data: Vec<u8>) -> Self

Constructs an instance from a vector without validating its size.
Source§

fn to_slice_unchecked(&'a self, dst: &mut [u8])

Serializes the instance to a mutable slice without checking the destination size.
Source§

fn from_bytes_(data: &'a mut [u8]) -> Result<Self, Error>

Creates an instance of the type from a mutable byte slice, checking for size constraints. Read more
Source§

fn to_slice(&'a self, dst: &mut [u8]) -> Result<usize, Error>

Serializes the instance to a mutable slice, checking the destination size.
Source§

impl<'a> TryFrom<DecodableField<'a>> for U24

Source§

type Error = Error

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

fn try_from(value: DecodableField<'a>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a> TryFrom<EncodableField<'a>> for U24

Source§

type Error = Error

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

fn try_from(value: EncodableField<'a>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<u32> for U24

Source§

type Error = Error

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

fn try_from(value: u32) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Copy for U24

Source§

impl Eq for U24

Source§

impl StructuralPartialEq for U24

Auto Trait Implementations§

§

impl Freeze for U24

§

impl RefUnwindSafe for U24

§

impl Send for U24

§

impl Sync for U24

§

impl Unpin for U24

§

impl UnwindSafe for U24

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<'a, T> Encodable for T
where T: Into<EncodableField<'a>>,

Source§

fn to_bytes(self, dst: &mut [u8]) -> Result<usize, Error>

Encodes the object into the provided byte slice. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> GetSize for T
where T: Fixed,

Source§

fn get_size(&self) -> usize

get_size returns total size of the type in bytes.
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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SizeHint for T
where T: Fixed,

Source§

fn size_hint(_data: &[u8], _offset: usize) -> Result<usize, Error>

size_hint is a static method that takes the raw data and an offset and returns the total size of the encoded message. This is particularly useful for types where the encoded size may vary based on the contents of the data, and we need to calculate how much space is required for decoding.
Source§

fn size_hint_(&self, _: &[u8], _offset: usize) -> Result<usize, Error>

size_hint_ is an instance method that performs the same function but allows the size to be be determined with respect to the current instance of the type.
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.