Crate pass_it_on

Source
Expand description

§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 values and send them in the expected format to server.


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

FeatureDescription
clientEnables the client but not any particular interface.
discordEnables the discord webhook endpoint.
emailEnables the email endpoint.
endpointsEnables the Endpoint and EndpointConfig traits.
fileEnables the regular file endpoint.
httpEnables the HTTP interface client and server.
http-clientEnables the HTTP interface for just client.
http-serverEnables the HTTP interface for just server.
interfacesEnables the Interface and InterfaceConfig traits.
matrixEnables the matrix endpoint.
parse-cfgEnables parsing of client or server configurations from TOML when those features are also enabled.
pipeEnables the named pipe interface client and server. (Unix only)
pipe-clientEnables the named pipe interface client. (Unix only)
pipe-serverEnables the named pipe interface server. (Unix only)
serverEnables the server but not any particular interface or endpoint.
server-bin-fullEnables the building of the provided pass-it-on-server binary with all available interfaces and endpoints
server-bin-minimalEnables the building of the provided pass-it-on-server binary while not requiring any specific interface or endpoint
rustls-tls-native-rootsEnables rustls-tls-native-roots for reqwest.

Modules§

endpoints
Endpoints for the server
interfaces
Interfaces for the server and client
notifications
Representation of notification messages.

Structs§

ClientConfigFile
Serde compatible representation of ClientConfiguration
ClientConfiguration
Client configuration that can be used to start the client.
ServerConfigFile
Serde compatible representation of ServerConfiguration
ServerConfiguration
Server configuration that can be used to start the server.

Enums§

Error
Errors returned by pass-it-on library.

Functions§

start_client
Start the client with provided ClientConfiguration and Receiver<ClientReadyMessage> channel.
start_client_arc
Start the client with provided ClientConfiguration and Arc<Mutex<Vec<ClientReadyMessage>>>.
start_server
Start the server with provided ServerConfiguration.
verify_matrix_devices
Interactively verify devices for all Matrix endpoints in the provided ServerConfiguration.