Skip to main content

NumericTarget

Trait NumericTarget 

Source
pub trait NumericTarget:
    Sized
    + Copy
    + 'static {
    const TARGET: DT;

    // Required method
    fn widen_from(src: DT, bytes: &[u8]) -> Result<Vec<Self>, String>;
}
Expand description

Sealed trait implemented for each numeric primitive that the WXF derive / hand-impl path can read into. Each impl knows its target DT and how to widen from any compatible source DT.

Required Associated Constants§

Source

const TARGET: DT

The wire type this target maps to on the canonical (no-widening) path.

Required Methods§

Source

fn widen_from(src: DT, bytes: &[u8]) -> Result<Vec<Self>, String>

Build a Vec<Self> from a source data-type tag plus raw little-endian bytes. Returns Err(message) when the source can’t widen losslessly into Self (truncation, signedness change, precision loss).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl NumericTarget for f32

Source§

const TARGET: DT = DT::Real32

Source§

fn widen_from(src: DT, bytes: &[u8]) -> Result<Vec<Self>, String>

Source§

impl NumericTarget for f64

Source§

const TARGET: DT = DT::Real64

Source§

fn widen_from(src: DT, bytes: &[u8]) -> Result<Vec<Self>, String>

Source§

impl NumericTarget for i8

Source§

const TARGET: DT = DT::Integer8

Source§

fn widen_from(src: DT, bytes: &[u8]) -> Result<Vec<Self>, String>

Source§

impl NumericTarget for i16

Source§

const TARGET: DT = DT::Integer16

Source§

fn widen_from(src: DT, bytes: &[u8]) -> Result<Vec<Self>, String>

Source§

impl NumericTarget for i32

Source§

const TARGET: DT = DT::Integer32

Source§

fn widen_from(src: DT, bytes: &[u8]) -> Result<Vec<Self>, String>

Source§

impl NumericTarget for i64

Source§

const TARGET: DT = DT::Integer64

Source§

fn widen_from(src: DT, bytes: &[u8]) -> Result<Vec<Self>, String>

Source§

impl NumericTarget for u8

Source§

const TARGET: DT = DT::UnsignedInteger8

Source§

fn widen_from(src: DT, bytes: &[u8]) -> Result<Vec<Self>, String>

Source§

impl NumericTarget for u16

Source§

const TARGET: DT = DT::UnsignedInteger16

Source§

fn widen_from(src: DT, bytes: &[u8]) -> Result<Vec<Self>, String>

Source§

impl NumericTarget for u32

Source§

const TARGET: DT = DT::UnsignedInteger32

Source§

fn widen_from(src: DT, bytes: &[u8]) -> Result<Vec<Self>, String>

Source§

impl NumericTarget for u64

Source§

const TARGET: DT = DT::UnsignedInteger64

Source§

fn widen_from(src: DT, bytes: &[u8]) -> Result<Vec<Self>, String>

Implementors§

Source§

impl NumericTarget for Complex32

Source§

const TARGET: DT = DT::ComplexReal32

Source§

impl NumericTarget for Complex64

Source§

const TARGET: DT = DT::ComplexReal64