[][src]Crate repomon

Configuration management for repomon.

Examples

Read from TOML string

    let test_toml = r#"basedir = "/home/jozias/projects"

    [[repos.ar2.remotes]]
    name = "origin"
    url = "jozias@jasonozias.com:repos/ar2.git"

    [[repos.ar2.branch]]
    name = "master"
    interval = "1m"
    remotes = ["origin"]

    [[repos.repomon.remotes]]
    name = "origin"
    url = "jozias@jasonozias.com:repos/repomon.git"

    [[repos.repomon.remotes]]
    name = "gh"
    url = "git@github.com:rustyhorde/repomon.git"

    [[repos.repomon.branch]]
    name = "master"
   interval = "1m"
    remotes = ["origin", "gh"]

    [[repos.repomon.branch]]
    name = "feature/testing"
    interval = "1m"
    remotes = ["origin", "gh"]
    "#;

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

    // Check the `Repomon` struct.
    let repos = repomon.repos();
    assert_eq!(repos.keys().len(), 2);
    assert!(repos.contains_key("repomon"));
    assert!(repos.contains_key("ar2"));

Write to TOML string

      let mut repomon: Repomon = Default::default();
      repomon.set_basedir("/home/jozias/projects".to_string());
      repomon.set_repos(repo_map);

      // 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(&repomon, &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

Branch

A branch to monitor for changes.

Error

The Error type.

Message

Struct sent via tx to clients;

Remote

A remote to check a branch against

Repo

A repomon repository definition

Repomon

The base repomon config.

Enums

Category

Message category of the message being sent.

ErrorKind

The kind of an error.

Functions

read_toml

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

write_toml

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