commonware_p2p/authenticated/discovery/actors/peer/
ingress.rs

1use crate::authenticated::{discovery::types, Mailbox};
2use commonware_cryptography::PublicKey;
3
4/// Messages that can be sent to the peer [super::Actor].
5#[derive(Clone, Debug)]
6pub enum Message<C: PublicKey> {
7    /// Send a bit vector to the peer.
8    BitVec(types::BitVec),
9
10    /// Send a list of [types::Info] to the peer.
11    Peers(Vec<types::Info<C>>),
12
13    /// Kill the peer actor.
14    Kill,
15}
16
17impl<C: PublicKey> Mailbox<Message<C>> {
18    pub async fn bit_vec(&mut self, bit_vec: types::BitVec) {
19        let _ = self.send(Message::BitVec(bit_vec)).await;
20    }
21
22    pub async fn peers(&mut self, peers: Vec<types::Info<C>>) {
23        let _ = self.send(Message::Peers(peers)).await;
24    }
25
26    pub async fn kill(&mut self) {
27        let _ = self.send(Message::Kill).await;
28    }
29}