use crate::Result;
use crate::channel::Channel;
use crate::circuit::UniqId;
use async_trait::async_trait;
use futures::channel::mpsc;
use std::sync::Arc;
use tor_linkspec::HasRelayIds;
pub type ChannelResult = Result<Arc<Channel>>;
pub struct OutboundChanSender(pub(crate) mpsc::UnboundedSender<ChannelResult>);
impl OutboundChanSender {
#[allow(dead_code)] pub(crate) fn new(tx: mpsc::UnboundedSender<ChannelResult>) -> Self {
Self(tx)
}
pub fn send(self, result: ChannelResult) {
let _ = self.0.unbounded_send(result);
}
}
#[async_trait]
pub trait ChannelProvider {
type BuildSpec: HasRelayIds;
fn get_or_launch(
self: Arc<Self>,
reactor_id: UniqId,
target: Self::BuildSpec,
tx: OutboundChanSender,
) -> Result<()>;
}