use crate::{Frame, Result, Target};
use async_trait::async_trait;
use std::sync::Arc;
#[async_trait]
pub trait Endpoint {
fn size_hint(&self) -> usize;
async fn send(&self, frame: Frame, target: Target) -> Result<()>;
async fn next(&self) -> Result<(Frame, Target)>;
}
#[async_trait]
impl<T: Endpoint + Send + Sync> Endpoint for Arc<T> {
fn size_hint(&self) -> usize {
T::size_hint(self)
}
async fn send(&self, frame: Frame, target: Target) -> Result<()> {
T::send(self, frame, target).await
}
async fn next(&self) -> Result<(Frame, Target)> {
T::next(self).await
}
}