pub trait MacBackend: Clone {
type SendError;
type CapacityError;
// Required methods
async fn add_peer(
&self,
key: PublicKey,
) -> Result<PeerId, MacBackendError<Self::SendError, Self::CapacityError>>;
async fn add_private_channel(
&self,
key: ChannelKey,
) -> Result<(), MacBackendError<Self::SendError, Self::CapacityError>>;
async 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>>;
async fn fill_random(&self, dest: &mut [u8]);
async fn now_ms(&self) -> u64;
async fn register_ephemeral(
&self,
parent: LocalIdentityId,
identity: SoftwareIdentity,
) -> Result<LocalIdentityId, MacBackendError<Self::SendError, Self::CapacityError>>;
async fn remove_ephemeral(&self, id: LocalIdentityId) -> bool;
}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§
Sourcetype CapacityError
type CapacityError
Error type returned by fixed-capacity operations.
Required Methods§
Sourceasync fn add_peer(
&self,
key: PublicKey,
) -> Result<PeerId, MacBackendError<Self::SendError, Self::CapacityError>>
async fn add_peer( &self, key: PublicKey, ) -> Result<PeerId, MacBackendError<Self::SendError, Self::CapacityError>>
Add or refresh a peer.
Sourceasync fn add_private_channel(
&self,
key: ChannelKey,
) -> Result<(), MacBackendError<Self::SendError, Self::CapacityError>>
async fn add_private_channel( &self, key: ChannelKey, ) -> Result<(), MacBackendError<Self::SendError, Self::CapacityError>>
Add or refresh a private channel.
Sourceasync fn add_named_channel(
&self,
name: &str,
) -> Result<(), MacBackendError<Self::SendError, Self::CapacityError>>
async fn add_named_channel( &self, name: &str, ) -> Result<(), MacBackendError<Self::SendError, Self::CapacityError>>
Add or refresh a named channel.
Sourceasync fn send_broadcast(
&self,
from: LocalIdentityId,
payload: &[u8],
options: &SendOptions,
) -> Result<SendReceipt, MacBackendError<Self::SendError, Self::CapacityError>>
async fn send_broadcast( &self, from: LocalIdentityId, payload: &[u8], options: &SendOptions, ) -> Result<SendReceipt, MacBackendError<Self::SendError, Self::CapacityError>>
Queue a broadcast frame.
Sourceasync fn send_multicast(
&self,
from: LocalIdentityId,
channel: &ChannelId,
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>>
Queue a multicast frame.
Sourceasync fn send_unicast(
&self,
from: LocalIdentityId,
dst: &PublicKey,
payload: &[u8],
options: &SendOptions,
) -> Result<Option<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>>
Queue a unicast frame.
Sourceasync fn send_blind_unicast(
&self,
from: LocalIdentityId,
dst: &PublicKey,
channel: &ChannelId,
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>>
Queue a blind-unicast frame.
Sourceasync fn fill_random(&self, dest: &mut [u8])
async fn fill_random(&self, dest: &mut [u8])
Fill dest with random bytes.
async fn register_ephemeral( &self, parent: LocalIdentityId, identity: SoftwareIdentity, ) -> Result<LocalIdentityId, MacBackendError<Self::SendError, Self::CapacityError>>
async fn remove_ephemeral(&self, id: LocalIdentityId) -> bool
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.