pub trait FakeNetworkSpec: Sized {
type Context: WithFakeTimerContext<Self::TimerId>;
type TimerId: Clone;
type SendMeta;
type RecvMeta;
// Required methods
fn handle_frame(
ctx: &mut Self::Context,
recv: Self::RecvMeta,
data: Buf<Vec<u8>>,
);
fn handle_timer(
ctx: &mut Self::Context,
dispatch: Self::TimerId,
timer: FakeTimerId,
);
fn process_queues(ctx: &mut Self::Context) -> bool;
fn fake_frames(
ctx: &mut Self::Context,
) -> &mut impl WithFakeFrameContext<Self::SendMeta>;
// Provided method
fn new_network<CtxId, Links, I>(
contexts: I,
links: Links,
) -> FakeNetwork<Self, CtxId, Links>
where CtxId: Eq + Hash + Copy + Debug,
I: IntoIterator<Item = (CtxId, Self::Context)>,
Links: FakeNetworkLinks<Self::SendMeta, Self::RecvMeta, CtxId> { ... }
}
Expand description
A network spec that defines a FakeNetwork
.
Required Associated Types§
Sourcetype Context: WithFakeTimerContext<Self::TimerId>
type Context: WithFakeTimerContext<Self::TimerId>
The context type, which represents a node in the network.
Sourcetype TimerId: Clone
type TimerId: Clone
The type of timer IDs handled by Self::Context
.
Required Methods§
Sourcefn handle_frame(
ctx: &mut Self::Context,
recv: Self::RecvMeta,
data: Buf<Vec<u8>>,
)
fn handle_frame( ctx: &mut Self::Context, recv: Self::RecvMeta, data: Buf<Vec<u8>>, )
Handles a single received frame by ctx
.
Sourcefn handle_timer(
ctx: &mut Self::Context,
dispatch: Self::TimerId,
timer: FakeTimerId,
)
fn handle_timer( ctx: &mut Self::Context, dispatch: Self::TimerId, timer: FakeTimerId, )
Handles a single timer id in ctx
.
dispatch
is the timer’s dispatch identifier, i.e., an implementer of
HandleableTimer
. timer
is the unique timer identifier for the fake
timer that fired.
Sourcefn process_queues(ctx: &mut Self::Context) -> bool
fn process_queues(ctx: &mut Self::Context) -> bool
Processes any context-internal queues, returning true
if any work
was done.
This is used to drive queued frames that may be sitting inside the
context and invisible to the FakeNetwork
.
Sourcefn fake_frames(
ctx: &mut Self::Context,
) -> &mut impl WithFakeFrameContext<Self::SendMeta>
fn fake_frames( ctx: &mut Self::Context, ) -> &mut impl WithFakeFrameContext<Self::SendMeta>
Extracts accesses to fake frames from Self::Context
.
Provided Methods§
Sourcefn new_network<CtxId, Links, I>(
contexts: I,
links: Links,
) -> FakeNetwork<Self, CtxId, Links>where
CtxId: Eq + Hash + Copy + Debug,
I: IntoIterator<Item = (CtxId, Self::Context)>,
Links: FakeNetworkLinks<Self::SendMeta, Self::RecvMeta, CtxId>,
fn new_network<CtxId, Links, I>(
contexts: I,
links: Links,
) -> FakeNetwork<Self, CtxId, Links>where
CtxId: Eq + Hash + Copy + Debug,
I: IntoIterator<Item = (CtxId, Self::Context)>,
Links: FakeNetworkLinks<Self::SendMeta, Self::RecvMeta, CtxId>,
Creates a new fake network from this spec.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.