Struct erpc_scanner::relay::RelaysPool
source · pub struct RelaysPool<'a, T> {
pub relays_hashmap: HashMap<String, (Relay<'a>, T)>,
}
Expand description
RelaysPool stores the hashmap of Fingerprint of the Relay and the Relay itself and provides the
abstraction to get the reference to the relay through the get_relay(fingerprint)
method
The RelaysPool holds the hashmap of <RELAY_FINGERPRINT, tor_netdir::Relay>, so that the Tor
Network graph stores only data enough to index the Relay i.e the RELAY_FINGERPRINT and
whenever it needs some data related to a certain relay, it simply requests this pool a
reference to the tor_netdir::Relay through get_relay(RELAY_FINGERPRINT)
method
where RELAY_FINGERPRINT is a string that represents the stringified RSA ID of the relay
Fields§
§relays_hashmap: HashMap<String, (Relay<'a>, T)>
Maps <Fingerprint, Relay>
Implementations§
source§impl<'a, T: Clone> RelaysPool<'a, T>
impl<'a, T: Clone> RelaysPool<'a, T>
sourcepub fn from_relays(relays: &[(Relay<'a>, T)]) -> Self
pub fn from_relays(relays: &[(Relay<'a>, T)]) -> Self
Takes the NetDir and creaates a RelaysPool
Why not get Arc
sourcepub fn get_relay<S: AsRef<str>>(
&self,
fingerprint: S
) -> Option<&(Relay<'a>, T)>
pub fn get_relay<S: AsRef<str>>( &self, fingerprint: S ) -> Option<&(Relay<'a>, T)>
Gets you the reference to the Relay as you provide the fingerprint of the relay
sourcepub fn add_relay<S: ToString>(&mut self, fingerprint: S, relay: Relay<'a>, v: T)
pub fn add_relay<S: ToString>(&mut self, fingerprint: S, relay: Relay<'a>, v: T)
Add a tor_netdir::Relay<'_>
into the RelaysPool with a certain fingerprint as the key
sourcepub fn total_relays(&self) -> usize
pub fn total_relays(&self) -> usize
Calculate total no of Relays in the RelaysPool
Auto Trait Implementations§
impl<'a, T> RefUnwindSafe for RelaysPool<'a, T>where
T: RefUnwindSafe,
impl<'a, T> Send for RelaysPool<'a, T>where
T: Send,
impl<'a, T> Sync for RelaysPool<'a, T>where
T: Sync,
impl<'a, T> Unpin for RelaysPool<'a, T>where
T: Unpin,
impl<'a, T> UnwindSafe for RelaysPool<'a, T>where
T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.