intrepid_core/frame/frame_outbox.rs
use futures::{channel::mpsc, SinkExt};
use tower::BoxError;
use super::Frame;
/// An outbox for sending frames to an actionable stream.
///
pub struct FrameOutbox(mpsc::Sender<Frame>);
impl FrameOutbox {
/// Send a frame to the stream.
pub async fn send(&mut self, frame: impl Into<Frame>) -> Result<(), BoxError> {
self.0.send(frame.into()).await.map_err(Into::into)
}
/// Create a new frame outbox from a channel sender.
pub fn new(tx: mpsc::Sender<Frame>) -> Self {
Self(tx)
}
}