[][src]Struct toml::Encoder

pub struct Encoder {
    pub toml: Table,
    // some fields omitted
}

A structure to transform Rust values into TOML values.

This encoder implements the serialization Encoder interface, allowing Encodable rust types to be fed into the encoder. The output of this encoder is a TOML Table structure. The resulting TOML can be stringified if necessary.

Example

extern crate rustc_serialize;
extern crate toml;

use toml::{Encoder, Value};
use rustc_serialize::Encodable;

#[derive(RustcEncodable)]
struct MyStruct { foo: isize, bar: String }
let my_struct = MyStruct { foo: 4, bar: "hello!".to_string() };

let mut e = Encoder::new();
my_struct.encode(&mut e).unwrap();

assert_eq!(e.toml.get(&"foo".to_string()), Some(&Value::Integer(4)))

Fields

toml: Table

Output TOML that is emitted. The current version of this encoder forces the top-level representation of a structure to be a table.

This field can be used to extract the return value after feeding a value into this Encoder.

Implementations

impl Encoder[src]

pub fn new() -> Encoder[src]

Constructs a new encoder which will emit to the given output stream.

Trait Implementations

impl Encoder for Encoder[src]

type Error = Error

The error type for method results.

Auto Trait Implementations

impl RefUnwindSafe for Encoder

impl Send for Encoder

impl Sync for Encoder

impl Unpin for Encoder

impl UnwindSafe for Encoder

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<S> EncoderHelpers for S where
    S: Encoder
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.