Skip to main content

CryptoProvider

Trait CryptoProvider 

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

    // Required methods
    fn send(
        &self,
        communication: &Com,
        sessions: &Ses,
        message: OutgoingMessage,
    ) -> impl Future<Output = Result<(), Self::SendError>> + Send + Sync;
    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 + IpcErrorKind

Source

type ReceiveError: Debug + Send + Sync + 'static + IpcErrorKind

Required Methods§

Source

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

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.

Both recoverable and fatal errors may be returned, classified via IpcErrorKind::is_fatal(). A recoverable error (e.g. a handshake timeout or a transient transport failure) is logged and the IPC client keeps running; a fatal error (e.g. the session storage being inaccessible) stops the client from processing any further messages. Ambiguous cases should be classified as recoverable.

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.

Both recoverable and fatal errors may be returned, classified via IpcErrorKind::is_fatal(). A recoverable error (e.g. a malformed frame from one peer or a transient transport failure) is logged and the IPC client’s processing loop continues; a fatal error (e.g. the session storage being inaccessible) stops the loop. Ambiguous cases should be classified as recoverable.

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§