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§
Sourcetype CapacityError
type CapacityError
Error type returned by fixed-capacity operations.
Required Methods§
Sourcefn add_peer(
&self,
key: PublicKey,
) -> Result<PeerId, MacBackendError<Self::SendError, Self::CapacityError>>
fn add_peer( &self, key: PublicKey, ) -> Result<PeerId, MacBackendError<Self::SendError, Self::CapacityError>>
Add or refresh a peer.
Sourcefn add_private_channel(
&self,
key: ChannelKey,
) -> Result<(), MacBackendError<Self::SendError, Self::CapacityError>>
fn add_private_channel( &self, key: ChannelKey, ) -> Result<(), MacBackendError<Self::SendError, Self::CapacityError>>
Add or refresh a private channel.
Sourcefn add_named_channel(
&self,
name: &str,
) -> Result<(), MacBackendError<Self::SendError, Self::CapacityError>>
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.
Sourcefn fill_random(
&self,
dest: &mut [u8],
) -> Result<(), MacBackendError<Self::SendError, Self::CapacityError>>
fn fill_random( &self, dest: &mut [u8], ) -> Result<(), MacBackendError<Self::SendError, Self::CapacityError>>
Fill dest with random bytes.
Sourcefn now_ms(
&self,
) -> Result<u64, MacBackendError<Self::SendError, Self::CapacityError>>
fn now_ms( &self, ) -> Result<u64, MacBackendError<Self::SendError, Self::CapacityError>>
Return the current MAC clock time.
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>>
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.