pub trait WriteBinProtExt: Write {
    fn bin_write_unit(&mut self) -> Result<(), Error> { ... }
    fn bin_write_bool(&mut self, b: bool) -> Result<(), Error> { ... }
    fn bin_write_char(&mut self, c: char) -> Result<usize, Error> { ... }
    fn bin_write_integer<T: Into<i64>>(&mut self, n: T) -> Result<usize, Error> { ... }
    fn bin_write_nat0<T: Into<u64>>(&mut self, n: T) -> Result<usize, Error> { ... }
    fn bin_write_float32(&mut self, f: &f32) -> Result<usize, Error> { ... }
    fn bin_write_float64(&mut self, f: &f64) -> Result<usize, Error> { ... }
    fn bin_write_variant_index(&mut self, i: u8) -> Result<usize, Error> { ... }
    fn bin_write_polyvar_tag(&mut self, i: u32) -> Result<usize, Error> { ... }
}
Expand description

extension trait for writers implementing io::Write to allow them to write the primitive values for bin_prot

Provided Methods

Write a unit

Write a bool

Write a single char character

Write a variable length integer

bin_prot also supports a slightly different encoding called Nat0 This is an unsigned integer type that is used internally by the protocol for storing sizes of lists etc. < 0x000000080 -> lower 8 bits of the integer (1 byte) < 0x000010000 -> CODE_INT16 followed by lower 16 bits of integer (3 bytes) < 0x100000000 -> CODE_INT32 followed by lower 32 bits of integer (5 bytes) >= 0x100000000 -> CODE_INT64 followed by all 64 bits of integer (9 bytes)

Write a float

Write a 64 bit float

for enums/variants with n variants the variant index is written out as follows: n <= 256 -> write out lower 8 bits of n (1 byte) n <= 65536 -> write out lower 16 bits of n (2 bytes) WARNING: This does not implement the requirement above It is tricky to determine how many variants an enum has at runtime and therfore to know which of the above cases to use This assumes all enums have < 256 variants This probably catches 99% of cases but is not strictly in compliance with the protocol

For Polyvar types write the 4 bytes of the tag/hash for a variant You can convert between ocaml native integer using (x >> 1)

Implementors

All types that implement Write get methods defined in WriteBinProtIntegerExt for free.