Trait tor_hsservice::internal_prelude::NetDirProvider

source ·
pub(crate) trait NetDirProvider: UpcastArcNetDirProvider + Send + Sync {
    // Required methods
    fn netdir(&self, timeliness: Timeliness) -> Result<Arc<NetDir>, Error>;
    fn events(&self) -> Pin<Box<dyn Stream<Item = DirEvent> + Send>>;
    fn params(&self) -> Arc<dyn AsRef<NetParameters>>;

    // Provided method
    fn timely_netdir(&self) -> Result<Arc<NetDir>, Error> { ... }
}
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>, Error>

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

source

fn events(&self) -> Pin<Box<dyn Stream<Item = DirEvent> + Send>>

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>, Error>

Return a reasonable netdir for general usage.

This is an alias for NetDirProvider::netdir(Timeliness::Timely).

Implementors§