Struct rmp_serialize::encode::Encoder
[−]
[src]
pub struct Encoder<'a> { /* fields omitted */ }Represents MessagePack serialization implementation.
Note
MessagePack has no specification about how to encode variant types. Thus we are free to do whatever we want, so the given chose may be not ideal for you.
Every Rust variant value can be represented as a tuple of index and a value.
All instances of ErrorKind::Interrupted are handled by this function and the underlying
operation is retried.
Methods
impl<'a> Encoder<'a>[src]
fn new(wr: &'a mut Write) -> Encoder<'a>
Creates a new MessagePack encoder whose output will be written to the writer specified.
Trait Implementations
impl<'a> Encoder for Encoder<'a>[src]
type Error = Error
The error type for method results.
fn emit_nil(&mut self) -> Result<(), Error>
Emit a nil value. Read more
fn emit_bool(&mut self, val: bool) -> Result<(), Error>
Emit a bool value. Read more
fn emit_u8(&mut self, val: u8) -> Result<(), Error>
Emit a u8 value.
fn emit_u16(&mut self, val: u16) -> Result<(), Error>
Emit a u16 value.
fn emit_u32(&mut self, val: u32) -> Result<(), Error>
Emit a u32 value.
fn emit_u64(&mut self, val: u64) -> Result<(), Error>
Emit a u64 value.
fn emit_usize(&mut self, val: usize) -> Result<(), Error>
Emit a usize value.
fn emit_i8(&mut self, val: i8) -> Result<(), Error>
Emit a i8 value.
fn emit_i16(&mut self, val: i16) -> Result<(), Error>
Emit a i16 value.
fn emit_i32(&mut self, val: i32) -> Result<(), Error>
Emit a i32 value.
fn emit_i64(&mut self, val: i64) -> Result<(), Error>
Emit a i64 value.
fn emit_isize(&mut self, val: isize) -> Result<(), Error>
Emit a isize value.
fn emit_f32(&mut self, val: f32) -> Result<(), Error>
Emit a f32 value.
fn emit_f64(&mut self, val: f64) -> Result<(), Error>
Emit a f64 value.
fn emit_char(&mut self, val: char) -> Result<(), Error>
Emit a char value. Read more
fn emit_str(&mut self, val: &str) -> Result<(), Error>
Emit a string value.
fn emit_enum<F>(&mut self, _name: &str, f: F) -> Result<(), Error> where
F: FnOnce(&mut Self) -> Result<(), Error>,
F: FnOnce(&mut Self) -> Result<(), Error>,
Encodes and attempts to write the enum value into the Write.
Currently we encode variant types as a tuple of id with array of args, like: [id, [args...]]
fn emit_enum_variant<F>(
&mut self,
_name: &str,
id: usize,
len: usize,
f: F
) -> Result<(), Error> where
F: FnOnce(&mut Self) -> Result<(), Error>,
&mut self,
_name: &str,
id: usize,
len: usize,
f: F
) -> Result<(), Error> where
F: FnOnce(&mut Self) -> Result<(), Error>,
Encodes and attempts to write a concrete variant value.
fn emit_enum_variant_arg<F>(&mut self, _idx: usize, f: F) -> Result<(), Error> where
F: FnOnce(&mut Self) -> Result<(), Error>,
F: FnOnce(&mut Self) -> Result<(), Error>,
Encodes and attempts to write a concrete variant value arguments.
fn emit_enum_struct_variant<F>(
&mut self,
_name: &str,
_id: usize,
_len: usize,
_f: F
) -> Result<(), Error> where
F: FnOnce(&mut Self) -> Result<(), Error>,
&mut self,
_name: &str,
_id: usize,
_len: usize,
_f: F
) -> Result<(), Error> where
F: FnOnce(&mut Self) -> Result<(), Error>,
Emit a enumeration variant value with no or named data. Read more
fn emit_enum_struct_variant_field<F>(
&mut self,
_name: &str,
_idx: usize,
_f: F
) -> Result<(), Error> where
F: FnOnce(&mut Self) -> Result<(), Error>,
&mut self,
_name: &str,
_idx: usize,
_f: F
) -> Result<(), Error> where
F: FnOnce(&mut Self) -> Result<(), Error>,
Emit a named data item for an enumeration variant. Read more
fn emit_struct<F>(&mut self, _name: &str, len: usize, f: F) -> Result<(), Error> where
F: FnOnce(&mut Self) -> Result<(), Error>,
F: FnOnce(&mut Self) -> Result<(), Error>,
Emit a struct value. Read more
fn emit_struct_field<F>(
&mut self,
_name: &str,
_idx: usize,
f: F
) -> Result<(), Error> where
F: FnOnce(&mut Self) -> Result<(), Error>,
&mut self,
_name: &str,
_idx: usize,
f: F
) -> Result<(), Error> where
F: FnOnce(&mut Self) -> Result<(), Error>,
Emit a field item for a struct. Read more
fn emit_tuple<F>(&mut self, len: usize, f: F) -> Result<(), Error> where
F: FnOnce(&mut Self) -> Result<(), Error>,
F: FnOnce(&mut Self) -> Result<(), Error>,
Emit a tuple value. Read more
fn emit_tuple_arg<F>(&mut self, _idx: usize, f: F) -> Result<(), Error> where
F: FnOnce(&mut Self) -> Result<(), Error>,
F: FnOnce(&mut Self) -> Result<(), Error>,
Emit a data item for a tuple. Read more
fn emit_tuple_struct<F>(
&mut self,
_name: &str,
len: usize,
f: F
) -> Result<(), Error> where
F: FnOnce(&mut Self) -> Result<(), Error>,
&mut self,
_name: &str,
len: usize,
f: F
) -> Result<(), Error> where
F: FnOnce(&mut Self) -> Result<(), Error>,
Emit a tuple struct value. Read more
fn emit_tuple_struct_arg<F>(&mut self, _idx: usize, f: F) -> Result<(), Error> where
F: FnOnce(&mut Self) -> Result<(), Error>,
F: FnOnce(&mut Self) -> Result<(), Error>,
Emit a data item for a tuple struct. Read more
fn emit_option<F>(&mut self, f: F) -> Result<(), Error> where
F: FnOnce(&mut Self) -> Result<(), Error>,
F: FnOnce(&mut Self) -> Result<(), Error>,
Emit an optional value. Read more
fn emit_option_none(&mut self) -> Result<(), Error>
Emit the None optional value. Read more
fn emit_option_some<F>(&mut self, f: F) -> Result<(), Error> where
F: FnOnce(&mut Self) -> Result<(), Error>,
F: FnOnce(&mut Self) -> Result<(), Error>,
Emit the Some(x) optional value. Read more
fn emit_seq<F>(&mut self, len: usize, f: F) -> Result<(), Error> where
F: FnOnce(&mut Self) -> Result<(), Error>,
F: FnOnce(&mut Self) -> Result<(), Error>,
Emit a sequence of values. Read more
fn emit_seq_elt<F>(&mut self, _idx: usize, f: F) -> Result<(), Error> where
F: FnOnce(&mut Self) -> Result<(), Error>,
F: FnOnce(&mut Self) -> Result<(), Error>,
Emit an element in a sequence. Read more
fn emit_map<F>(&mut self, len: usize, f: F) -> Result<(), Error> where
F: FnOnce(&mut Self) -> Result<(), Error>,
F: FnOnce(&mut Self) -> Result<(), Error>,
Emit an associative container (map). Read more
fn emit_map_elt_key<F>(&mut self, _idx: usize, f: F) -> Result<(), Error> where
F: FnOnce(&mut Self) -> Result<(), Error>,
F: FnOnce(&mut Self) -> Result<(), Error>,
Emit the key for an entry in a map. Read more
fn emit_map_elt_val<F>(&mut self, _idx: usize, f: F) -> Result<(), Error> where
F: FnOnce(&mut Self) -> Result<(), Error>,
F: FnOnce(&mut Self) -> Result<(), Error>,
Emit the value for an entry in a map. Read more