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 NetDirs, 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§

source

fn netdir(&self, timeliness: Timeliness) -> Result<Arc<NetDir>>

Return a network directory that’s live according to the provided timeliness.

source

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.

source

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§

source

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,

source§

fn netdir(&self, timeliness: Timeliness) -> Result<Arc<NetDir>>

source§

fn timely_netdir(&self) -> Result<Arc<NetDir>>

source§

fn events(&self) -> BoxStream<'static, DirEvent>

source§

fn params(&self) -> Arc<dyn AsRef<NetParameters>>

Implementors§

source§

impl NetDirProvider for TestNetDirProvider

Available on crate feature testing only.