Decoder

Trait Decoder 

Source
pub trait Decoder: Sized {
    // Required method
    fn decode(reader: &mut Bytes) -> Result<Self>;
}
Expand description

Trait for types that can be decoded from the senax binary format.

Implement this trait for your type to enable deserialization. Most users should use #[derive(Decode)] instead of manual implementation.

§Errors

Returns EncoderError if the value cannot be decoded or the data is invalid.

Required Methods§

Source

fn decode(reader: &mut Bytes) -> Result<Self>

Decode the value from the given buffer with schema evolution support.

This method expects field IDs and type tags for forward/backward compatibility. Use this when you need schema evolution support.

§Arguments
  • reader - The buffer to read the encoded bytes from.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Decoder for bool

Decodes a bool from a single tag byte.

§Errors

Returns an error if the tag is not TAG_ZERO or TAG_ONE.

Source§

fn decode(reader: &mut Bytes) -> Result<Self>

Source§

impl Decoder for char

Decodes a char from its Unicode code point.

§Errors

Returns an error if the code point is not a valid Unicode scalar value.

Source§

fn decode(reader: &mut Bytes) -> Result<Self>

Source§

impl Decoder for f32

Decodes an f32 from a scientific notation string, legacy binary format, or i128.

This decoder supports:

  • New string format (TAG_STRING_BASE..TAG_STRING_LONG)
  • Legacy binary format (TAG_F32, TAG_F64)
  • i128 cross-decode (TAG_ZERO..TAG_U128, TAG_NEGATIVE)
Source§

fn decode(reader: &mut Bytes) -> Result<Self>

Source§

impl Decoder for f64

Decodes an f64 from a scientific notation string, legacy binary format, or i128.

This decoder supports:

  • New string format (TAG_STRING_BASE..TAG_STRING_LONG)
  • Legacy binary format (TAG_F64)
  • i128 cross-decode (TAG_ZERO..TAG_U128, TAG_NEGATIVE)
Source§

fn decode(reader: &mut Bytes) -> Result<Self>

Source§

impl Decoder for i8

Decodes a i8 from the bit-inverted encoding.

§Errors

Returns an error if the tag is not valid for an i8.

Source§

fn decode(reader: &mut Bytes) -> Result<Self>

Source§

impl Decoder for i16

Source§

fn decode(reader: &mut Bytes) -> Result<Self>

Source§

impl Decoder for i32

Source§

fn decode(reader: &mut Bytes) -> Result<Self>

Source§

impl Decoder for i64

Source§

fn decode(reader: &mut Bytes) -> Result<Self>

Source§

impl Decoder for i128

Source§

fn decode(reader: &mut Bytes) -> Result<Self>

Source§

impl Decoder for isize

Source§

fn decode(reader: &mut Bytes) -> Result<Self>

Source§

impl Decoder for u8

Decodes a u8 from the compact format.

Source§

fn decode(reader: &mut Bytes) -> Result<Self>

Source§

impl Decoder for u16

Source§

fn decode(reader: &mut Bytes) -> Result<Self>

Source§

impl Decoder for u32

Decodes a u32 from the compact format.

Source§

fn decode(reader: &mut Bytes) -> Result<Self>

Source§

impl Decoder for u64

Decodes a u64 from the compact format.

Source§

fn decode(reader: &mut Bytes) -> Result<Self>

Source§

impl Decoder for u128

Source§

fn decode(reader: &mut Bytes) -> Result<Self>

Source§

impl Decoder for ()

Source§

fn decode(reader: &mut Bytes) -> Result<Self>

Source§

impl Decoder for usize

Source§

fn decode(reader: &mut Bytes) -> Result<Self>

Source§

impl Decoder for String

Decodes a String from the senax binary format.

Source§

fn decode(reader: &mut Bytes) -> Result<Self>

Source§

impl Decoder for Bytes

Source§

fn decode(reader: &mut Bytes) -> Result<Self>

Source§

impl<K: Decoder + Eq + Hash, V: Decoder> Decoder for HashMap<K, V>

Decodes a map from the senax binary format.

Source§

fn decode(reader: &mut Bytes) -> Result<Self>

Source§

impl<K: Decoder + Ord, V: Decoder> Decoder for BTreeMap<K, V>

Source§

fn decode(reader: &mut Bytes) -> Result<Self>

Source§

impl<T0: Decoder> Decoder for (T0,)

Source§

fn decode(reader: &mut Bytes) -> Result<Self>

Source§

impl<T0: Decoder, T1: Decoder> Decoder for (T0, T1)

Source§

fn decode(reader: &mut Bytes) -> Result<Self>

Source§

impl<T0: Decoder, T1: Decoder, T2: Decoder> Decoder for (T0, T1, T2)

Source§

fn decode(reader: &mut Bytes) -> Result<Self>

Source§

impl<T0: Decoder, T1: Decoder, T2: Decoder, T3: Decoder> Decoder for (T0, T1, T2, T3)

Source§

fn decode(reader: &mut Bytes) -> Result<Self>

Source§

impl<T0: Decoder, T1: Decoder, T2: Decoder, T3: Decoder, T4: Decoder> Decoder for (T0, T1, T2, T3, T4)

Source§

fn decode(reader: &mut Bytes) -> Result<Self>

Source§

impl<T0: Decoder, T1: Decoder, T2: Decoder, T3: Decoder, T4: Decoder, T5: Decoder> Decoder for (T0, T1, T2, T3, T4, T5)

Source§

fn decode(reader: &mut Bytes) -> Result<Self>

Source§

impl<T0: Decoder, T1: Decoder, T2: Decoder, T3: Decoder, T4: Decoder, T5: Decoder, T6: Decoder> Decoder for (T0, T1, T2, T3, T4, T5, T6)

Source§

fn decode(reader: &mut Bytes) -> Result<Self>

Source§

impl<T0: Decoder, T1: Decoder, T2: Decoder, T3: Decoder, T4: Decoder, T5: Decoder, T6: Decoder, T7: Decoder> Decoder for (T0, T1, T2, T3, T4, T5, T6, T7)

Source§

fn decode(reader: &mut Bytes) -> Result<Self>

Source§

impl<T0: Decoder, T1: Decoder, T2: Decoder, T3: Decoder, T4: Decoder, T5: Decoder, T6: Decoder, T7: Decoder, T8: Decoder> Decoder for (T0, T1, T2, T3, T4, T5, T6, T7, T8)

Source§

fn decode(reader: &mut Bytes) -> Result<Self>

Source§

impl<T0: Decoder, T1: Decoder, T2: Decoder, T3: Decoder, T4: Decoder, T5: Decoder, T6: Decoder, T7: Decoder, T8: Decoder, T9: Decoder> Decoder for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)

Source§

fn decode(reader: &mut Bytes) -> Result<Self>

Source§

impl<T0: Decoder, T1: Decoder, T2: Decoder, T3: Decoder, T4: Decoder, T5: Decoder, T6: Decoder, T7: Decoder, T8: Decoder, T9: Decoder, T10: Decoder> Decoder for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)

Source§

fn decode(reader: &mut Bytes) -> Result<Self>

Source§

impl<T0: Decoder, T1: Decoder, T2: Decoder, T3: Decoder, T4: Decoder, T5: Decoder, T6: Decoder, T7: Decoder, T8: Decoder, T9: Decoder, T10: Decoder, T11: Decoder> Decoder for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)

Source§

fn decode(reader: &mut Bytes) -> Result<Self>

Source§

impl<T: Decoder + 'static> Decoder for Vec<T>

Decodes a Vec<T> from the senax binary format.

Source§

fn decode(reader: &mut Bytes) -> Result<Self>

Source§

impl<T: Decoder + Eq + Hash + 'static> Decoder for HashSet<T>

Decodes a set from the senax binary format.

Source§

fn decode(reader: &mut Bytes) -> Result<Self>

Source§

impl<T: Decoder + Ord + 'static> Decoder for BTreeSet<T>

Source§

fn decode(reader: &mut Bytes) -> Result<Self>

Source§

impl<T: Decoder> Decoder for Option<T>

Decodes an Option<T> from the senax binary format.

Source§

fn decode(reader: &mut Bytes) -> Result<Self>

Source§

impl<T: Decoder> Decoder for Box<T>

Decodes a Box<T> by decoding the inner value and wrapping it in a Box.

Source§

fn decode(reader: &mut Bytes) -> Result<Self>

Source§

impl<T: Decoder> Decoder for Arc<T>

Decodes an Arc<T> by decoding the inner value and wrapping it in an Arc.

Source§

fn decode(reader: &mut Bytes) -> Result<Self>

Source§

impl<T: Decoder, const N: usize> Decoder for [T; N]

Decodes a fixed-size array from the senax binary format.

Source§

fn decode(reader: &mut Bytes) -> Result<Self>

Implementors§