use super::ProxyConfig;
#[derive(Clone, Debug)]
pub struct ProxyChain {
pub(crate) proxies: Vec<ProxyConfig>,
}
impl ProxyChain {
pub fn new(proxies: Vec<ProxyConfig>) -> Self {
Self { proxies }
}
pub fn single(proxy: ProxyConfig) -> Self {
Self {
proxies: vec![proxy],
}
}
pub fn len(&self) -> usize {
self.proxies.len()
}
pub(crate) fn route_identity(&self) -> super::config::ProxyRouteIdentity {
super::config::ProxyRouteIdentity::from_configs(&self.proxies)
}
pub fn is_empty(&self) -> bool {
self.proxies.is_empty()
}
pub fn first(&self) -> Option<&ProxyConfig> {
self.proxies.first()
}
pub fn iter(&self) -> impl Iterator<Item = &ProxyConfig> {
self.proxies.iter()
}
}