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