Struct tor_netdir::testprovider::TestNetDirProvider
source · 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
Auto Trait Implementations§
impl !Freeze for TestNetDirProvider
impl RefUnwindSafe for TestNetDirProvider
impl Send for TestNetDirProvider
impl Sync for TestNetDirProvider
impl Unpin for TestNetDirProvider
impl UnwindSafe for TestNetDirProvider
Blanket Implementations§
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>