1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//! A protocol and a communication library for a mostly line-based key/value
//! protocol.
//!
//! # Communication buffers
//! _blather_ defines a few buffers which it uses to send and receive
//! information over its communication module.
//!
//! ## Telegrams
//! The most central communication buffer is [`Telegram`], which
//! consists of a _topic_ and zero or more key/value pairs, where each key must
//! be unique.
//!
//! ```
//! use blather::Telegram;
//!
//! let mut tg = Telegram::new("AddUser");
//!
//! tg.add_param("Name", "Frank Foobar");
//! tg.add_param("Job", "Secret Agent");
//! tg.add_param("Age", "42");
//!
//! assert_eq!(tg.get_topic(), "AddUser");
//! assert_eq!(tg.get_str("Name").unwrap(), "Frank Foobar");
//! assert_eq!(tg.get_fromstr::<u32, _>("Nonexistent").unwrap(), None);
//! assert_eq!(tg.get_fromstr::<u8, _>("Age").unwrap(), Some(42));
//! ```
//!
//! ## Params
//! These are simple key/value pairs, which can be seen as `HashMap`'s with
//! some restrictions on key names.
//!
//! ```
//! use blather::Params;
//!
//! let mut params = Params::new();
//!
//! params.add_param("Name", "Frank Foobar");
//! params.add_param("Job", "Secret Agent");
//! params.add_param("Age", "42");
//!
//! assert_eq!(params.get_str("Name").unwrap(), "Frank Foobar");
//! assert_eq!(params.get_fromstr::<u8, _>("Age").unwrap(), Some(42));
//! ```
//!
//! A set of "parameters", represented by the Params struct, is a set of
//! key/value pairs. They look similar to `Telegrams` because the `Telegram`'s
//! implement their key/value paris using a `Params` buffer.
//!
//! # Communication
//! blather handles transmission using tokio-util's
//! [`Framed`](tokio_util::codec::Framed) framework, by
//! implementing its own [`Codec`]. It can be used to send and
//! receive the various communication buffers supported by the crate.
pub use Codec;
pub use ;
pub use ;
pub use Params;
pub use Telegram;
// vim: set ft=rust et sw=2 ts=2 sts=2 cinoptions=2 tw=79 :