pub struct TestNetDirProvider { /* private fields */ }Available on crate feature
testing only.Expand description
Helper implementation of a NetDirProvider.
A TestNetDirProvider can be used to provide a netdir in a single
situation that requires a NetDirProvider.
It notifies its owner of changes
by firing a NewConsensus event
each time TestNetDirProvider::set_netdir_and_notify is called.
Calling TestNetDirProvider::set_netdir will not trigger a notification.
Implementations§
Source§impl TestNetDirProvider
impl TestNetDirProvider
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new TestNetDirProvider with no netdir available.
Sourcepub fn set_netdir(&self, dir: impl Into<Arc<NetDir>>)
pub fn set_netdir(&self, dir: impl Into<Arc<NetDir>>)
Replace the NetDir in this TestNetDirProvider.
Sourcepub async fn set_netdir_and_notify(&self, dir: impl Into<Arc<NetDir>>)
pub async fn set_netdir_and_notify(&self, dir: impl Into<Arc<NetDir>>)
Replace the NetDir in this TestNetDirProvider,
firing a NewConsensus event.
Trait Implementations§
Source§impl Debug for TestNetDirProvider
impl Debug for TestNetDirProvider
Source§impl From<NetDir> for TestNetDirProvider
impl From<NetDir> for TestNetDirProvider
Source§impl NetDirProvider for TestNetDirProvider
impl NetDirProvider for TestNetDirProvider
Source§fn 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.Source§fn 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. Read more
Source§fn params(&self) -> Arc<dyn AsRef<NetParameters>>
fn params(&self) -> Arc<dyn AsRef<NetParameters>>
Return the latest network parameters. Read more
Source§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. Read more
Source§fn timely_netdir(&self) -> Result<Arc<NetDir>>
fn timely_netdir(&self) -> Result<Arc<NetDir>>
Return a reasonable netdir for general usage. Read more
Source§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<'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.Source§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,
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,
Auto Trait Implementations§
impl !Freeze for TestNetDirProvider
impl RefUnwindSafe for TestNetDirProvider
impl Send for TestNetDirProvider
impl Sync for TestNetDirProvider
impl Unpin for TestNetDirProvider
impl UnsafeUnpin for TestNetDirProvider
impl UnwindSafe for TestNetDirProvider
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> PossiblyOption<T> for T
impl<T> PossiblyOption<T> for T
Source§impl<T> UpcastArcNetDirProvider for Twhere
T: NetDirProvider,
impl<T> UpcastArcNetDirProvider for Twhere
T: NetDirProvider,
Source§fn upcast_arc<'a>(self: Arc<T>) -> Arc<dyn NetDirProvider + 'a>where
T: 'a,
fn upcast_arc<'a>(self: Arc<T>) -> Arc<dyn NetDirProvider + 'a>where
T: 'a,
Return a view of this object as an
Arc<dyn NetDirProvider>