use std::sync::mpsc::Sender;
use crate::backend;
pub trait Resolver: Send + 'static {
fn run(&mut self, s: Sender<BackendMsg>);
}
pub struct BackendAddedMsg {
pub key: backend::BackendKey,
pub backend: backend::Backend,
}
impl PartialEq for BackendAddedMsg {
fn eq(&self, other: &Self) -> bool {
self.key == other.key
}
}
impl Eq for BackendAddedMsg {}
pub struct BackendRemovedMsg(pub backend::BackendKey);
pub enum BackendMsg {
AddedMsg(BackendAddedMsg),
RemovedMsg(BackendRemovedMsg),
#[doc(hidden)]
StopMsg,
#[doc(hidden)]
HeartbeatMsg,
}
impl PartialEq for BackendMsg {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(BackendMsg::AddedMsg(a), BackendMsg::AddedMsg(b)) => a == b,
(BackendMsg::RemovedMsg(a), BackendMsg::RemovedMsg(b)) => {
a.0 == b.0
}
(BackendMsg::StopMsg, BackendMsg::StopMsg) => true,
(BackendMsg::HeartbeatMsg, BackendMsg::HeartbeatMsg) => true,
_ => false,
}
}
}
impl Eq for BackendMsg {}
pub enum BackendAction {
BackendAdded,
BackendRemoved,
}