use super::backend::MultiPeerBackend;
use crate::endpoint::Endpoint;
use crate::transport::AcceptStopHandle;
use std::collections::HashMap;
#[cfg(feature = "inproc")]
use std::collections::HashSet;
use std::sync::Arc;
#[doc(hidden)]
pub struct SocketCommon<B: MultiPeerBackend + 'static> {
pub backend: Arc<B>,
pub binds: HashMap<Endpoint, AcceptStopHandle>,
pub last_endpoint: Option<Endpoint>,
#[cfg(feature = "inproc")]
pub ignored_warned: HashSet<&'static str>,
}
impl<B: MultiPeerBackend + 'static> SocketCommon<B> {
pub(crate) fn new(backend: Arc<B>) -> Self {
Self {
backend,
binds: HashMap::new(),
last_endpoint: None,
#[cfg(feature = "inproc")]
ignored_warned: HashSet::new(),
}
}
}
#[doc(hidden)]
pub trait HasCommon {
type Backend: MultiPeerBackend + 'static;
fn common(&self) -> &SocketCommon<Self::Backend>;
fn common_mut(&mut self) -> &mut SocketCommon<Self::Backend>;
}