Skip to main content

ToFormat

Trait ToFormat 

Source
pub trait ToFormat {
    // Required method
    fn to_format<F: Format, M: Meter>(
        &self,
        meter: &mut M,
    ) -> Result<F, MeterError>;
}
Expand description

Render self into any Format sink. Designed for use by code that wants to expose a statically typed Rust value (e.g. each field of ProtocolConfig) through one of the Format-implementing wire types (serde_json::Value, prost_types::Value, etc.) without having to enumerate the destination type at the call site.

Integer types wider than 32 bits are rendered through Format::string rather than Format::number because Format::number is defined to take u32. This also matches the convention used elsewhere in the codebase to dodge the IEEE-754 precision loss that bites JavaScript clients consuming JSON numbers above 2^53.

Required Methods§

Source

fn to_format<F: Format, M: Meter>(&self, meter: &mut M) -> Result<F, MeterError>

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 ToFormat for &str

Source§

fn to_format<F: Format, M: Meter>(&self, meter: &mut M) -> Result<F, MeterError>

Source§

impl ToFormat for String

Source§

fn to_format<F: Format, M: Meter>(&self, meter: &mut M) -> Result<F, MeterError>

Source§

impl ToFormat for bool

Source§

fn to_format<F: Format, M: Meter>(&self, meter: &mut M) -> Result<F, MeterError>

Source§

impl ToFormat for u8

Source§

fn to_format<F: Format, M: Meter>(&self, meter: &mut M) -> Result<F, MeterError>

Source§

impl ToFormat for u16

Source§

fn to_format<F: Format, M: Meter>(&self, meter: &mut M) -> Result<F, MeterError>

Source§

impl ToFormat for u32

Source§

fn to_format<F: Format, M: Meter>(&self, meter: &mut M) -> Result<F, MeterError>

Source§

impl ToFormat for u64

Source§

fn to_format<F: Format, M: Meter>(&self, meter: &mut M) -> Result<F, MeterError>

Source§

impl ToFormat for u128

Source§

fn to_format<F: Format, M: Meter>(&self, meter: &mut M) -> Result<F, MeterError>

Source§

impl ToFormat for usize

Source§

fn to_format<F: Format, M: Meter>(&self, meter: &mut M) -> Result<F, MeterError>

Source§

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

Source§

fn to_format<F: Format, M: Meter>(&self, meter: &mut M) -> Result<F, MeterError>

Source§

impl<T1: ToFormat, T2: ToFormat, T3: ToFormat> ToFormat for (T1, T2, T3)

Source§

fn to_format<F: Format, M: Meter>(&self, meter: &mut M) -> Result<F, MeterError>

Source§

impl<T1: ToFormat, T2: ToFormat> ToFormat for (T1, T2)

Source§

fn to_format<F: Format, M: Meter>(&self, meter: &mut M) -> Result<F, MeterError>

Source§

impl<T: ToFormat> ToFormat for Option<T>

Source§

fn to_format<F: Format, M: Meter>(&self, meter: &mut M) -> Result<F, MeterError>

Source§

impl<T: ToFormat> ToFormat for Vec<T>

Source§

fn to_format<F: Format, M: Meter>(&self, meter: &mut M) -> Result<F, MeterError>

Source§

impl<T: ToFormat> ToFormat for [T]

Source§

fn to_format<F: Format, M: Meter>(&self, meter: &mut M) -> Result<F, MeterError>

Implementors§