Skip to main content

RingContract

Struct RingContract 

Source
pub struct RingContract {
    pub max_concurrent_push: u8,
    pub max_concurrent_pop: u8,
    pub ordering: OrderingContract,
    pub capacity_bound: Option<u32>,
}
Expand description

Declared operation envelope for a ring. The two count bounds use 0 to mean “unbounded”.

Fields§

§max_concurrent_push: u8

Max concurrently-registered producers (0 = unbounded).

§max_concurrent_pop: u8

Max concurrently-registered consumers (0 = unbounded).

§ordering: OrderingContract

The ordering envelope the consumers may observe.

§capacity_bound: Option<u32>

Optional hard ceiling on ring capacity (None = unbounded).

Implementations§

Source§

impl RingContract

Source

pub fn from_counts(max_producers: usize, max_consumers: usize) -> Self

A contract that PINS the peer counts: registration past max_producers / max_consumers returns TooManyProducers / TooManyConsumers instead of growing the ring. No ordering constraint, no capacity bound. The common fixed-topology declaration.

Source

pub fn unbounded() -> Self

The fully-unbounded contract: any peer counts, any capacity, no ordering constraint. The DEFAULT for rings with no declared contract - registration never fails under it (peers grow the ring on demand up to the substrate slot ceilings).

Source

pub fn permits_producer(&self, active: usize) -> bool

May another producer attach, given active are registered?

Source

pub fn permits_consumer(&self, active: usize) -> bool

May another consumer attach, given active are registered?

Source

pub fn permits_capacity(&self, capacity: usize) -> bool

Is a ring of capacity slots legal under the contract?

Source

pub fn permits_shape(&self, shape: RingShape) -> bool

Is shape legal under the ordering contract? Global total order is preserved only by the single-stream Spsc and the shared-sequence Vyukov; the partitioned per-producer-lane shapes (Mpsc, Mpmc) interleave producers, so both are illegal under a Fifo contract. Every other contract permits every shape (FifoPerProducer is exactly what the lanes deliver).

Source

pub fn permits_config(&self, shape: RingShape, capacity: usize) -> bool

Feasible-region oracle for an adaptive policy: is a candidate (shape, capacity) configuration legal? A policy filters every move it proposes through this, so an aggressive auto-morph cannot violate the declared envelope.

Trait Implementations§

Source§

impl Clone for RingContract

Source§

fn clone(&self) -> RingContract

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for RingContract

Source§

impl Debug for RingContract

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for RingContract

Source§

impl PartialEq for RingContract

Source§

fn eq(&self, other: &RingContract) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for RingContract

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.

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> 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.