Trait NetDirProvider
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>>;
fn protocol_statuses(&self) -> Option<(SystemTime, Arc<ProtoStatuses>)>;
// Provided methods
fn timely_netdir(&self) -> Result<Arc<NetDir>, Error> { ... }
fn wait_for_netdir<'life0, 'async_trait>(
&'life0 self,
timeliness: Timeliness,
) -> Pin<Box<dyn Future<Output = Result<Arc<NetDir>, NetdirProviderShutdown>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: '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 'life0: 'async_trait,
'life1: 'async_trait,
Self: '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§
fn netdir(&self, timeliness: Timeliness) -> Result<Arc<NetDir>, Error>
fn netdir(&self, timeliness: Timeliness) -> Result<Arc<NetDir>, Error>
Return a network directory that’s live according to the provided
timeliness
.
fn events(&self) -> Pin<Box<dyn Stream<Item = DirEvent> + Send>>
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.
fn 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.
fn protocol_statuses(&self) -> Option<(SystemTime, Arc<ProtoStatuses>)>
fn protocol_statuses(&self) -> Option<(SystemTime, Arc<ProtoStatuses>)>
Return the latest set of recommended and required protocols, if there is one.
This may be more recent (or more available) than this provider’s associated NetDir.
Provided Methods§
fn timely_netdir(&self) -> Result<Arc<NetDir>, Error>
fn timely_netdir(&self) -> Result<Arc<NetDir>, Error>
Return a reasonable netdir for general usage.
This is an alias for
NetDirProvider::netdir
(
Timeliness::Timely
)
.
fn wait_for_netdir<'life0, 'async_trait>(
&'life0 self,
timeliness: Timeliness,
) -> Pin<Box<dyn Future<Output = Result<Arc<NetDir>, NetdirProviderShutdown>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: '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
'life0: 'async_trait,
Self: 'async_trait,
Get a NetDir from provider
, waiting until one exists.
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
'life0: 'async_trait,
'life1: 'async_trait,
Self: '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
'life0: 'async_trait,
'life1: 'async_trait,
Self: '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.