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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
//! # Pass-It-On
//! A library that provides simple notification client and server that receives messages and passes them on to endpoints
//!
//!
//! ## Client Example
//! To use the client to pass messages to the server you will need to pass a valid [`ClientConfiguration`]
//! and a channel receiver to the start client function. It will monitor that channel for incoming
//! [`Notification`][crate::notifications::Notification] values and send them in the expected format to server.
//!
//! ```
//! # use pass_it_on::notifications::{Key, Notification};
//! # use pass_it_on::{ClientConfigFileParser, start_client, Error};
//! # use tokio::sync::mpsc;
//! #
//! # const CLIENT_TOML_CONFIG: &str = r#"
//! # [client]
//! # key = "UVXu7wtbXHWNgAr6rWyPnaZbZK9aYin8"
//! #
//! # [[client.interface]]
//! # type = "http"
//! # port = 8080
//! #
//! # "#;
//!
//! # #[tokio::main]
//! async fn main() -> Result<(), Error> {
//! const NOTIFICATION_NAME: &str = "test1";
//! let config = ClientConfiguration::from_toml(CLIENT_TOML_CONFIG)?;
//! let (interface_tx, interface_rx) = mpsc::channel(100);
//!
//! let messages = vec![
//! Message::new("A message to be sent").to_client_ready_message(NOTIFICATION_NAME),
//! Message::new("Another message").to_client_ready_message(NOTIFICATION_NAME),
//! ];
//!
//! for message in messages {
//! if let Err(send_error) = interface_tx.send(message).await {
//! println!("Send Error: {}", send_error);
//! }
//! }
//!
//! start_client(config, interface_rx, None).await?;
//!
//! Ok(())
//! }
//! ```
//!
//! ## Feature Flags
//!
//! | Feature | Description |
//! |-------------------------|------------------------------------------------------------------------------------------------------------------------|
//! | client | Enables the client but not any particular interface. |
//! | discord | Enables the discord webhook endpoint. |
//! | email | Enables the email endpoint. |
//! | endpoints | Enables the Endpoint and EndpointConfig traits. |
//! | file | Enables the regular file endpoint. |
//! | http | Enables the HTTP interface client and server. |
//! | http-client | Enables the HTTP interface for just client. |
//! | http-server | Enables the HTTP interface for just server. |
//! | interfaces | Enables the Interface and InterfaceConfig traits. |
//! | matrix | Enables the matrix endpoint. |
//! | parse-cfg | Enables parsing of client or server configurations from TOML when those features are also enabled. |
//! | pipe | Enables the named pipe interface client and server. **(Unix only)** |
//! | pipe-client | Enables the named pipe interface client. **(Unix only)** |
//! | pipe-server | Enables the named pipe interface server. **(Unix only)** |
//! | server | Enables the server but not any particular interface or endpoint. |
//! | server-bin-full | Enables the building of the provided `pass-it-on-server` binary with all available interfaces and endpoints |
//! | server-bin-minimal | Enables the building of the provided `pass-it-on-server` binary while not requiring any specific interface or endpoint |
//! | rustls-tls-native-roots | Enables rustls-tls-native-roots for reqwest. |
pub
pub use ;
pub use ClientConfigFile;
pub use ServerConfigFile;
pub use ClientConfiguration;
pub use ServerConfiguration;
pub use Error;
pub use start_server;
pub use verify_matrix_devices;
const CRATE_VERSION: &str = env!;
const CHANNEL_BUFFER: usize = 200;
const KEY_CONTEXT: &str = "pass-it-on 2024-02-18 client-server shared-key";