MacBackend

Trait MacBackend 

Source
pub trait MacBackend: Clone {
    type SendError;
    type CapacityError;

    // Required methods
    fn add_peer(
        &self,
        key: PublicKey,
    ) -> Result<PeerId, MacBackendError<Self::SendError, Self::CapacityError>>;
    fn add_private_channel(
        &self,
        key: ChannelKey,
    ) -> Result<(), MacBackendError<Self::SendError, Self::CapacityError>>;
    fn add_named_channel(
        &self,
        name: &str,
    ) -> Result<(), MacBackendError<Self::SendError, Self::CapacityError>>;
    async fn send_broadcast(
        &self,
        from: LocalIdentityId,
        payload: &[u8],
        options: &SendOptions,
    ) -> Result<SendReceipt, MacBackendError<Self::SendError, Self::CapacityError>>;
    async fn send_multicast(
        &self,
        from: LocalIdentityId,
        channel: &ChannelId,
        payload: &[u8],
        options: &SendOptions,
    ) -> Result<SendReceipt, MacBackendError<Self::SendError, Self::CapacityError>>;
    async fn send_unicast(
        &self,
        from: LocalIdentityId,
        dst: &PublicKey,
        payload: &[u8],
        options: &SendOptions,
    ) -> Result<Option<SendReceipt>, MacBackendError<Self::SendError, Self::CapacityError>>;
    async fn send_blind_unicast(
        &self,
        from: LocalIdentityId,
        dst: &PublicKey,
        channel: &ChannelId,
        payload: &[u8],
        options: &SendOptions,
    ) -> Result<Option<SendReceipt>, MacBackendError<Self::SendError, Self::CapacityError>>;
    fn fill_random(
        &self,
        dest: &mut [u8],
    ) -> Result<(), MacBackendError<Self::SendError, Self::CapacityError>>;
    fn now_ms(
        &self,
    ) -> Result<u64, MacBackendError<Self::SendError, Self::CapacityError>>;
    fn register_ephemeral(
        &self,
        parent: LocalIdentityId,
        identity: SoftwareIdentity,
    ) -> Result<LocalIdentityId, MacBackendError<Self::SendError, Self::CapacityError>>;
    fn remove_ephemeral(
        &self,
        id: LocalIdentityId,
    ) -> Result<bool, MacBackendError<Self::SendError, Self::CapacityError>>;
}
Expand description

Pluggable backend that the node layer delegates to for MAC operations.

MacHandle implements MacBackend, and test code can provide a lightweight fake.

Required Associated Types§

Source

type SendError

Error type returned by send-oriented operations.

Source

type CapacityError

Error type returned by fixed-capacity operations.

Required Methods§

Source

fn add_peer( &self, key: PublicKey, ) -> Result<PeerId, MacBackendError<Self::SendError, Self::CapacityError>>

Add or refresh a peer.

Source

fn add_private_channel( &self, key: ChannelKey, ) -> Result<(), MacBackendError<Self::SendError, Self::CapacityError>>

Add or refresh a private channel.

Source

fn add_named_channel( &self, name: &str, ) -> Result<(), MacBackendError<Self::SendError, Self::CapacityError>>

Add or refresh a named channel.

Source

async fn send_broadcast( &self, from: LocalIdentityId, payload: &[u8], options: &SendOptions, ) -> Result<SendReceipt, MacBackendError<Self::SendError, Self::CapacityError>>

Queue a broadcast frame.

Source

async fn send_multicast( &self, from: LocalIdentityId, channel: &ChannelId, payload: &[u8], options: &SendOptions, ) -> Result<SendReceipt, MacBackendError<Self::SendError, Self::CapacityError>>

Queue a multicast frame.

Source

async fn send_unicast( &self, from: LocalIdentityId, dst: &PublicKey, payload: &[u8], options: &SendOptions, ) -> Result<Option<SendReceipt>, MacBackendError<Self::SendError, Self::CapacityError>>

Queue a unicast frame.

Source

async fn send_blind_unicast( &self, from: LocalIdentityId, dst: &PublicKey, channel: &ChannelId, payload: &[u8], options: &SendOptions, ) -> Result<Option<SendReceipt>, MacBackendError<Self::SendError, Self::CapacityError>>

Queue a blind-unicast frame.

Source

fn fill_random( &self, dest: &mut [u8], ) -> Result<(), MacBackendError<Self::SendError, Self::CapacityError>>

Fill dest with random bytes.

Source

fn now_ms( &self, ) -> Result<u64, MacBackendError<Self::SendError, Self::CapacityError>>

Return the current MAC clock time.

Source

fn register_ephemeral( &self, parent: LocalIdentityId, identity: SoftwareIdentity, ) -> Result<LocalIdentityId, MacBackendError<Self::SendError, Self::CapacityError>>

Source

fn remove_ephemeral( &self, id: LocalIdentityId, ) -> Result<bool, MacBackendError<Self::SendError, Self::CapacityError>>

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.

Implementations on Foreign Types§

Source§

impl<'a, P: Platform, const IDENTITIES: usize, const PEERS: usize, const CHANNELS: usize, const ACKS: usize, const TX: usize, const FRAME: usize, const DUP: usize> MacBackend for MacHandle<'a, P, IDENTITIES, PEERS, CHANNELS, ACKS, TX, FRAME, DUP>

Source§

type SendError = SendError

Source§

type CapacityError = CapacityError

Source§

fn add_peer( &self, key: PublicKey, ) -> Result<PeerId, MacBackendError<Self::SendError, Self::CapacityError>>

Source§

fn add_private_channel( &self, key: ChannelKey, ) -> Result<(), MacBackendError<Self::SendError, Self::CapacityError>>

Source§

fn add_named_channel( &self, name: &str, ) -> Result<(), MacBackendError<Self::SendError, Self::CapacityError>>

Source§

async fn send_broadcast( &self, from: LocalIdentityId, payload: &[u8], options: &SendOptions, ) -> Result<SendReceipt, MacBackendError<Self::SendError, Self::CapacityError>>

Source§

async fn send_multicast( &self, from: LocalIdentityId, channel: &ChannelId, payload: &[u8], options: &SendOptions, ) -> Result<SendReceipt, MacBackendError<Self::SendError, Self::CapacityError>>

Source§

async fn send_unicast( &self, from: LocalIdentityId, dst: &PublicKey, payload: &[u8], options: &SendOptions, ) -> Result<Option<SendReceipt>, MacBackendError<Self::SendError, Self::CapacityError>>

Source§

async fn send_blind_unicast( &self, from: LocalIdentityId, dst: &PublicKey, channel: &ChannelId, payload: &[u8], options: &SendOptions, ) -> Result<Option<SendReceipt>, MacBackendError<Self::SendError, Self::CapacityError>>

Source§

fn fill_random( &self, dest: &mut [u8], ) -> Result<(), MacBackendError<Self::SendError, Self::CapacityError>>

Source§

fn now_ms( &self, ) -> Result<u64, MacBackendError<Self::SendError, Self::CapacityError>>

Source§

fn register_ephemeral( &self, parent: LocalIdentityId, identity: SoftwareIdentity, ) -> Result<LocalIdentityId, MacBackendError<Self::SendError, Self::CapacityError>>

Source§

fn remove_ephemeral( &self, id: LocalIdentityId, ) -> Result<bool, MacBackendError<Self::SendError, Self::CapacityError>>

Implementors§