pub struct Oracle<P: PublicKey, E: Clock> { /* 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, E: Clock> Oracle<P, E>
impl<P: PublicKey, E: Clock> Oracle<P, E>
Sourcepub fn manager(&self) -> Manager<P, E>
pub fn manager(&self) -> Manager<P, E>
Create a new Manager.
Useful for mocking crate::authenticated::discovery.
Sourcepub fn socket_manager(&self) -> SocketManager<P, E>
pub fn socket_manager(&self) -> SocketManager<P, E>
Create a new SocketManager.
Useful for mocking crate::authenticated::lookup.
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.
Bandwidth can be specified before a peer is registered or linked.
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.
Link can be called before a peer is registered or bandwidth is specified.
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, E> Freeze for Oracle<P, E>
impl<P, E> !RefUnwindSafe for Oracle<P, E>
impl<P, E> Send for Oracle<P, E>
impl<P, E> Sync for Oracle<P, E>
impl<P, E> Unpin for Oracle<P, E>
impl<P, E> !UnwindSafe for Oracle<P, E>
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)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>
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>
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