Builder

Struct Builder 

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

Options builder.

Implementations§

Source§

impl Builder

Source

pub const fn integer(self, integer: Integer) -> Self

Indicates if an integer serialization should be variable.

§Examples
use musli::options::{self, Integer, Options};

const OPTIONS: Options = options::new().integer(Integer::Fixed).build();
Source

pub const fn float(self, float: Float) -> Self

Indicates the configuration of float serialization.

§Examples
use musli::options::{self, Float, Options};

const OPTIONS: Options = options::new().float(Float::Fixed).build();
Source

pub const fn byte_order(self, byte_order: ByteOrder) -> Self

Specify which byte order to use.

§Examples
use musli::options::{self, ByteOrder, Options};

const OPTIONS: Options = options::new().byte_order(ByteOrder::Little).build();
Source

pub const fn native_byte_order(self) -> Self

Specify that the ByteOrder::NATIVE byte order should be used.

§Examples
use musli::options::{self, Width, Options};

const OPTIONS: Options = options::new().native_byte_order().build();
Source

pub const fn pointer(self, width: Width) -> Self

Sets the way in which pointer-like usize and isize types are encoded.

§Examples
use musli::options::{self, Width, Options};

const OPTIONS: Options = options::new().pointer(Width::U32).build();
Source

pub const fn map_keys_as_numbers(self) -> Self

Configured a format to use numbers as map keys.

This options is used for an encoding such as JSON to allow for storing numbers as string keys, since this would otherwise not be possible and cause an error.

§Examples
use musli::options::{self, Options};

const OPTIONS: Options = options::new().map_keys_as_numbers().build();
Source

pub const fn fixed(self) -> Self

Configure the options to use fixed serialization.

This causes numerical types to use the default fixed-length serialization which is typically more efficient than variable-length through variable() but is less compact.

This is the same as calling integer(Integer::Fixed), float(Float::Fixed), and pointer(Width::NATIVE).

§Examples
use musli::options::{self, Options};

const OPTIONS: Options = options::new().fixed().build();
Source

pub const fn variable(self) -> Self

Configure the options to use variable serialization.

This causes numerical types to use the default variable-length serialization which is typically less efficient than fixed-length through fixed() but is more compact.

This is the same as calling integer(Integer::Variable), float(Float::Variable), and pointer(Width::Variable).

§Examples
use musli::options::{self, Options};

const OPTIONS: Options = options::new().variable().build();
Source

pub const fn build(self) -> Options

Built an options builder into a constant.

§Examples
use musli::options::{self, Options};

const OPTIONS: Options = options::new().variable().build();

Trait Implementations§

Source§

impl Debug for Builder

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.