Struct cbor::Encoder[][src]

pub struct Encoder<W> { /* fields omitted */ }

Encodes Rust values to CBOR bytes in the underlying writer W.

Note that currently, using the serialization infrastructure is the only way to write CBOR in this crate.

Methods

impl<W: Write> Encoder<W>
[src]

Encode CBOR to an arbitrary writer.

Encode an iterator of Rust values to CBOR in the underlying writer.

Every value in the iterator must satisfy Encodable (from the rustc-serialize crate).

Note that this encodes top-level CBOR data items. They can be decoded in a streaming fashion.

Example

Encode a list of numbers.

use cbor::Encoder;

let mut enc = Encoder::from_memory();
enc.encode(&[1, 2, 3, 4, 5]);
assert_eq!(vec![1, 2, 3, 4, 5], enc.as_bytes());

Flush the underlying writer.

impl Encoder<Vec<u8>>
[src]

Encode CBOR to an in memory buffer.

Flush and retrieve the CBOR bytes that have been written.

Flush and retrieve the CBOR bytes that have been written without copying.

Trait Implementations

impl<W: Write> RustcEncoder for Encoder<W>
[src]

The error type for method results.

Emit a nil value. Read more

Emit a usize value.

Emit a u64 value.

Emit a u32 value.

Emit a u16 value.

Emit a u8 value.

Emit a isize value.

Emit a i64 value.

Emit a i32 value.

Emit a i16 value.

Emit a i8 value.

Emit a f64 value.

Emit a f32 value.

Emit a bool value. Read more

Emit a char value. Read more

Emit a string value.

Emit an enumeration value. Read more

Emit a enumeration variant value with no or unnamed data. Read more

Emit an unnamed data item for an enumeration variant. Read more

Emit a enumeration variant value with no or named data. Read more

Emit a named data item for an enumeration variant. Read more

Emit a struct value. Read more

Emit a field item for a struct. Read more

Emit a tuple value. Read more

Emit a data item for a tuple. Read more

Emit a tuple struct value. Read more

Emit a data item for a tuple struct. Read more

Emit an optional value. Read more

Emit the None optional value. Read more

Emit the Some(x) optional value. Read more

Emit a sequence of values. Read more

Emit an element in a sequence. Read more

Emit an associative container (map). Read more

Emit the key for an entry in a map. Read more

Emit the value for an entry in a map. Read more

Auto Trait Implementations

impl<W> Send for Encoder<W> where
    W: Send

impl<W> Sync for Encoder<W> where
    W: Sync