Trait CryptoProvider

Source
pub trait CryptoProvider<Com, Ses>:
    Send
    + Sync
    + 'static{
    type Session: Send + Sync + 'static;
    type SendError: Debug + Send + Sync + 'static;
    type ReceiveError: Debug + Send + Sync + 'static;

    // Required methods
    fn send(
        &self,
        communication: &Com,
        sessions: &Ses,
        message: OutgoingMessage,
    ) -> impl Future<Output = Result<(), Self::SendError>> + Send;
    fn receive(
        &self,
        receiver: &Com::Receiver,
        communication: &Com,
        sessions: &Ses,
    ) -> impl Future<Output = Result<IncomingMessage, Self::ReceiveError>> + Send + Sync;
}

Required Associated Types§

Source

type Session: Send + Sync + 'static

Source

type SendError: Debug + Send + Sync + 'static

Source

type ReceiveError: Debug + Send + Sync + 'static

Required Methods§

Source

fn send( &self, communication: &Com, sessions: &Ses, message: OutgoingMessage, ) -> impl Future<Output = Result<(), Self::SendError>> + Send

Send a message.

Calling this function may result in multiple messages being sent, depending on the implementation of the trait. For example, if the destination does not have a session, the function may first send a message to establish a session and then send the original message. The implementation of this function should handle this logic.

An error should only be returned for fatal and unrecoverable errors e.g. if the session storage is full or cannot be accessed. Returning an error will cause the IPC client to stop processing messages.

Source

fn receive( &self, receiver: &Com::Receiver, communication: &Com, sessions: &Ses, ) -> impl Future<Output = Result<IncomingMessage, Self::ReceiveError>> + Send + Sync

Receive a message.

Calling this function may also result in messages being sent, depending on the trait implementation. For example, if an encrypted message is received from a destination that does not have a session. The function may then try to establish a session and then re-request the original message. The implementation of this function should handle this logic.

An error should only be returned for fatal and unrecoverable errors e.g. if the session storage is full or cannot be accessed. Returning an error will cause the IPC client to stop processing messages.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§