Trait tor_netdir::NetDirProvider
source · pub trait NetDirProvider: UpcastArcNetDirProvider + Send + Sync {
// Required methods
fn netdir(&self, timeliness: Timeliness) -> Result<Arc<NetDir>>;
fn events(&self) -> BoxStream<'static, DirEvent>;
fn params(&self) -> Arc<dyn AsRef<NetParameters>>;
// Provided method
fn timely_netdir(&self) -> Result<Arc<NetDir>> { ... }
}
Expand description
An object that can provide NetDir
s, as well as inform consumers when
they might have changed.
It is the responsibility of the implementor of NetDirProvider
to try to obtain an up-to-date NetDir
,
and continuously to maintain and update it.
In usual configurations, Arti uses tor_dirmgr::DirMgr
as its NetDirProvider
.
Required Methods§
sourcefn netdir(&self, timeliness: Timeliness) -> Result<Arc<NetDir>>
fn netdir(&self, timeliness: Timeliness) -> Result<Arc<NetDir>>
Return a network directory that’s live according to the provided
timeliness
.
sourcefn events(&self) -> BoxStream<'static, DirEvent>
fn events(&self) -> BoxStream<'static, DirEvent>
Return a new asynchronous stream that will receive notification whenever the consensus has changed.
Multiple events may be batched up into a single item: each time this stream yields an event, all you can assume is that the event has occurred at least once.
sourcefn params(&self) -> Arc<dyn AsRef<NetParameters>>
fn params(&self) -> Arc<dyn AsRef<NetParameters>>
Return the latest network parameters.
If we have no directory, return a reasonable set of defaults.
Provided Methods§
sourcefn timely_netdir(&self) -> Result<Arc<NetDir>>
fn timely_netdir(&self) -> Result<Arc<NetDir>>
Return a reasonable netdir for general usage.
This is an alias for
NetDirProvider::netdir
(
Timeliness::Timely
)
.
Implementations on Foreign Types§
source§impl<T> NetDirProvider for Arc<T>where
T: NetDirProvider,
impl<T> NetDirProvider for Arc<T>where
T: NetDirProvider,
Implementors§
impl NetDirProvider for TestNetDirProvider
testing
only.