Crate atter [] [src]

Configuration management for atter.

Examples

Read from TOML string

    let test_toml = r#"base_url = "http://docs.rs/atter"
    "#;

    // Serialize the TOML above into a `Config` struct.
    let mut reader = Cursor::new(test_toml);
    let config = read_toml(&mut reader)?;

    // Check the `Config` struct.
    let base_url = config.base_url();
    assert_eq!(base_url, "http://docs.rs/atter");

Write to TOML string

      // Setup the `Config` struct.
      let mut config: Config = Default::default();
      config.set_base_url("http://docs.rs/atter".to_string());

      // Write the TOML to the given buf.
      let mut buf = [0; 5000];

      // Wrapped to drop mutable borrow.
      {
        let mut writer = Cursor::new(&mut buf[..]);
        write_toml(&config, &mut writer)?;
      }

      // Check that the result is the same as the TOML above.
      let filtered = buf.iter().filter(|x| **x > 0).cloned().collect::<Vec<u8>>();
      assert_eq!(
          TEST_TOML,
          String::from_utf8(filtered).expect("Invalid UTF-8 in result")
      );

Structs

Config

The base atter config.

Error

The Error type.

Message

Struct sent via tx to clients;

Functions

read_toml

Read TOML from the given reader and deserialize into a Config struct.

write_toml

Write TOML serialized from the Config struct to the given writer.