pub trait Encoder {
    type Ok;
    type Err;

Show 21 methods fn emit_usize(&mut self, v: usize); fn emit_u128(&mut self, v: u128); fn emit_u64(&mut self, v: u64); fn emit_u32(&mut self, v: u32); fn emit_u16(&mut self, v: u16); fn emit_u8(&mut self, v: u8); fn emit_isize(&mut self, v: isize); fn emit_i128(&mut self, v: i128); fn emit_i64(&mut self, v: i64); fn emit_i32(&mut self, v: i32); fn emit_i16(&mut self, v: i16); fn emit_i8(&mut self, v: i8); fn emit_bool(&mut self, v: bool); fn emit_f64(&mut self, v: f64); fn emit_f32(&mut self, v: f32); fn emit_char(&mut self, v: char); fn emit_str(&mut self, v: &str); fn emit_raw_bytes(&mut self, s: &[u8]); fn finish(self) -> Result<Self::Ok, Self::Err>; fn emit_enum_variant<F>(&mut self, v_id: usize, f: F)
    where
        F: FnOnce(&mut Self)
, { ... } fn emit_fieldless_enum_variant<const ID: usize>(&mut self) { ... }
}
Expand description

A note about error handling.

Encoders may be fallible, but in practice failure is rare and there are so many nested calls that typical Rust error handling (via Result and ?) is pervasive and has non-trivial cost. Instead, impls of this trait must implement a delayed error handling strategy. If a failure occurs, they should record this internally, and all subsequent encoding operations can be processed or ignored, whichever is appropriate. Then when finish() is called, an error result should be returned to indicate the failure. If no failures occurred, then finish() should return a success result.

Required Associated Types

Required Methods

Provided Methods

Implementors