use crate::authenticated::{lookup::actors::tracker::Reservation, Mailbox};
use commonware_cryptography::PublicKey;
use commonware_runtime::{Sink, Stream};
use commonware_stream::encrypted::{Receiver, Sender};
use commonware_utils::channel::fallible::AsyncFallibleExt;
pub enum Message<Si: Sink, St: Stream, P: PublicKey> {
Spawn {
peer: P,
connection: (Sender<Si>, Receiver<St>),
reservation: Reservation<P>,
},
}
impl<Si: Sink, St: Stream, P: PublicKey> Mailbox<Message<Si, St, P>> {
pub async fn spawn(
&mut self,
connection: (Sender<Si>, Receiver<St>),
reservation: Reservation<P>,
) {
self.0
.send_lossy(Message::Spawn {
peer: reservation.metadata().public_key().clone(),
connection,
reservation,
})
.await;
}
}