Struct toml::Encoder
[−]
[src]
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 | 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 |