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 methods
fn timely_netdir(&self) -> Result<Arc<NetDir>> { ... }
fn wait_for_netdir<'life0, 'async_trait>(
&'life0 self,
timeliness: Timeliness,
) -> Pin<Box<dyn Future<Output = Result<Arc<NetDir>, NetdirProviderShutdown>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn wait_for_netdir_to_list<'life0, 'life1, 'async_trait>(
&'life0 self,
target: &'life1 RelayIds,
timeliness: Timeliness,
) -> Pin<Box<dyn Future<Output = Result<(), NetdirProviderShutdown>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}
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
)
.
Sourcefn wait_for_netdir<'life0, 'async_trait>(
&'life0 self,
timeliness: Timeliness,
) -> Pin<Box<dyn Future<Output = Result<Arc<NetDir>, NetdirProviderShutdown>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn wait_for_netdir<'life0, 'async_trait>(
&'life0 self,
timeliness: Timeliness,
) -> Pin<Box<dyn Future<Output = Result<Arc<NetDir>, NetdirProviderShutdown>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get a NetDir from provider
, waiting until one exists.
Sourcefn wait_for_netdir_to_list<'life0, 'life1, 'async_trait>(
&'life0 self,
target: &'life1 RelayIds,
timeliness: Timeliness,
) -> Pin<Box<dyn Future<Output = Result<(), NetdirProviderShutdown>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn wait_for_netdir_to_list<'life0, 'life1, 'async_trait>(
&'life0 self,
target: &'life1 RelayIds,
timeliness: Timeliness,
) -> Pin<Box<dyn Future<Output = Result<(), NetdirProviderShutdown>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Wait until provider
lists target
.
NOTE: This might potentially wait indefinitely, if target
is never actually
becomes listed in the directory. It will exit if the NetDirProvider
shuts down.
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.