pub struct Oracle<P: PublicKey> { /* private fields */ }Expand description
Interface for modifying the simulated network.
At any point, peers can be added/removed and links between said peers can be modified.
Implementations§
Source§impl<P: PublicKey> Oracle<P>
impl<P: PublicKey> Oracle<P>
Sourcepub fn control(&self, me: P) -> Control<P>
pub fn control(&self, me: P) -> Control<P>
Spawn an individual control interface for a peer in the simulated network.
Sourcepub async fn blocked(&mut self) -> Result<Vec<(P, P)>, Error>
pub async fn blocked(&mut self) -> Result<Vec<(P, P)>, Error>
Return a list of all blocked peers.
Sourcepub async fn limit_bandwidth(
&mut self,
public_key: P,
egress_cap: Option<usize>,
ingress_cap: Option<usize>,
) -> Result<(), Error>
pub async fn limit_bandwidth( &mut self, public_key: P, egress_cap: Option<usize>, ingress_cap: Option<usize>, ) -> Result<(), Error>
Set bandwidth limits for a peer.
Bandwidth is specified for the peer’s egress (upload) and ingress (download)
rates in bytes per second. Use None for unlimited bandwidth.
Sourcepub async fn add_link(
&mut self,
sender: P,
receiver: P,
config: Link,
) -> Result<(), Error>
pub async fn add_link( &mut self, sender: P, receiver: P, config: Link, ) -> Result<(), Error>
Create a unidirectional link between two peers.
Link can be called multiple times for the same sender/receiver. The latest setting will be used.
Sourcepub async fn remove_link(&mut self, sender: P, receiver: P) -> Result<(), Error>
pub async fn remove_link(&mut self, sender: P, receiver: P) -> Result<(), Error>
Remove a unidirectional link between two peers.
If no link exists, this will return an error.
Trait Implementations§
Auto Trait Implementations§
impl<P> Freeze for Oracle<P>
impl<P> !RefUnwindSafe for Oracle<P>
impl<P> Send for Oracle<P>
impl<P> Sync for Oracle<P>
impl<P> Unpin for Oracle<P>
impl<P> !UnwindSafe for Oracle<P>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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 more