Development Documentation (main branch) - For stable release docs, see docs.rs/eidetica
Skip to main content

SimNetwork

Struct SimNetwork 

Source
pub struct SimNetwork { /* private fields */ }
Expand description

In-memory message fabric shared by every SimTransport in a cluster, and the control handle a test uses to inject faults. A drop-in for HttpLoopback via ClusterBuilder::transport that additionally lets a test partition links and heal them.

Clone is a shared handle (an Arc inside): the copy a test keeps and the copies inside each peer’s transport all see the same fabric.

Implementations§

Source§

impl SimNetwork

Source

pub fn new() -> Self

A fresh, empty fabric.

Source

pub fn partition(&self, a: &Address, b: &Address)

Drop all traffic between a and b in both directions until heal. A send across a blocked link fails as a connection error, so an auto-sync peer’s queued entries stay pending and redeliver after heal — a message-level partition, finer than withholding exchange calls.

Source

pub fn heal(&self, a: &Address, b: &Address)

Restore traffic between a and b (both directions).

Source

pub fn heal_all(&self)

Restore every link in the fabric.

Source

pub fn set_manual_delivery(&self, manual: bool)

Capture SendEntries pushes instead of delivering them inline (true), or return to inline delivery (false). Flip this after setup (bootstrap / auto_sync) so only the entry pushes a test cares about get captured. Turning it back off does not flush the queue — already-captured messages still need an explicit deliver.

The two fault families compose with partition taking precedence: a send across a partitioned link fails as a connection error before capture is considered, so it parks in the retry queue rather than the in-flight queue. Manual delivery only ever captures pushes on links that are up. Tests generally use one family or the other, not both at once.

Source

pub fn pending(&self) -> Vec<usize>

The delivery handles of every captured-but-undelivered message, in the order they were sent. Pass these to deliver, duplicate or drop_message to drive an out-of-order, duplicated, or lossy schedule.

Source

pub async fn deliver(&self, seq: usize) -> bool

Deliver the captured message seq to its receiver and remove it from the queue. Delivering in an order other than pending returned is how a test reorders the wire. Returns false if no such message is queued (or its receiver has stopped).

Source

pub async fn deliver_one(&self) -> bool

Deliver the oldest captured message. Returns false when the queue is empty.

Source

pub async fn deliver_all(&self) -> usize

Deliver every captured message in send order, draining the queue. Returns the number delivered. (Delivery never enqueues more — the receiver’s handler processes entries, it doesn’t push back through this fabric.)

Source

pub fn duplicate(&self, seq: usize) -> Option<usize>

Clone captured message seq so it will be delivered a second time, modelling a duplicate on the wire. The copy gets a fresh handle and lands at the back of the queue; the original stays put. Returns the new handle, or None if seq isn’t queued. Idempotent sync must converge regardless.

Source

pub fn drop_message(&self, seq: usize) -> bool

Drop captured message seq without delivering it — a lost packet. Returns true if a message was removed.

Source

pub fn drop_all(&self) -> usize

Drop every captured message without delivering. Returns the number lost.

Trait Implementations§

Source§

impl Clone for SimNetwork

Source§

fn clone(&self) -> SimNetwork

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for SimNetwork

Source§

fn default() -> SimNetwork

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

§

impl<M> Meta for M
where M: Default,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,