pub struct WireEncoding<I = Variable, L = Variable, const P: usize = MAX_INLINE_LEN> where
    I: TypedIntegerEncoding,
    L: TypedUsizeEncoding, 
{ /* private fields */ }
Expand description

Setting up encoding with parameters.

Implementations

Construct a new WireEncoding instance which uses Variable integer encoding.

You can modify this using the available factory methods:

use musli_wire::{WireEncoding, Fixed, Variable};
use musli::{Encode, Decode};

const CONFIG: WireEncoding<Fixed, Variable> = WireEncoding::new()
    .with_fixed_integers();

#[derive(Debug, PartialEq, Encode, Decode)]
struct Struct<'a> {
    name: &'a str,
    age: u32,
}

let mut out = Vec::new();

let expected = Struct {
    name: "Aristotle",
    age: 61,
};

CONFIG.encode(&mut out, &expected)?;
let actual = CONFIG.decode(&out[..])?;

assert_eq!(expected, actual);

Configure the encoding to use variable integer encoding.

Configure the encoding to use fixed integer encoding.

Configure the encoding to use fixed integer little-endian encoding.

Configure the encoding to use fixed integer big-endian encoding.

Configure the encoding to use fixed integer network-endian encoding (Default).

Configure the encoding to use variable length encoding.

Configure the encoding to use fixed length 32-bit encoding when encoding lengths.

Configure the encoding to use fixed length 64-bit encoding when encoding lengths.

Modify the maximum pack sized allowwed in the wire format. This defaults to MAX_INLINE_LEN, a value that will fit unencoded in the Tag of the type.

Encode the given value to the given Writer using the current configuration.

Encode the given value to the given Write using the current configuration.

Encode the given value to a Vec using the current configuration.

Encode the given value to a fixed-size bytes using the current configuration.

Decode the given type T from the given Reader using the current configuration.

Decode the given type T from the given slice using the current configuration.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.