blob: a97d352f9e8df8c0bc4a741ad58948b47d11ea31 (
plain)
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
|
//! Helper types for making configuration parsing more comfortable for the developer
//!
//! This module contains types and functionality for defining configuration structs with less
//! overhead.
//!
//! For example, one might write a configuration struct like this:
//!
//!
//! ```rust
//! #[derive(Debug, serde::Deserialize, tedge_api::Config)]
//! struct MyConfig {
//! // The address to send data to
//! target_address: String,
//!
//! // The interval to send data in (in milliseconds)
//! interval: std::num::NonZeroU64,
//! }
//! ```
//!
//! To define that the configuration of a plugin has a `target_address` (which is a `String`) and a
//! `interval` which is a non-zero unsigned 64-bit integer.
//!
//! With types from this module, this configuration gets easier to write and automatically gets
//! more documentation (via the `tedge_api::Config` mechanisms).
//!
//! The above would be written like this:
//!
//! ```rust
//! # extern crate tedge_lib;
//! #[derive(Debug, serde::Deserialize, tedge_api::Config)]
//! struct MyConfig {
//! // The address to send data to
//! target_address: tedge_lib::config::Address,
//!
//! // The interval to send data in
//! interval: tedge_lib::config::Humantime,
//! }
//! ```
//!
//! By using the [Address](crate::config::Address) type, we get user documentation on how an
//! address might look like. Using the [Humantime](crate::config::Humantime) type, we get
//! human-readable time configuration (e.g. "5 mins") plus nice user documentation for our
//! configuration type.
//!
mod address;
pub use crate::config::address::Address;
mod humantime;
pub use crate::config::humantime::Humantime;
mod one_or_many;
pub use one_or_many::OneOrMany;
mod port;
pub use port::Port;
mod socket_addr;
pub use socket_addr::SocketAddr;
|