Skip to main content

TestNoStdRuntime

Struct TestNoStdRuntime 

Source
pub struct TestNoStdRuntime<C, T, const NODE_COUNT: usize, const EDGE_COUNT: usize>{ /* private fields */ }
Expand description

A tiny, no_std test runtime:

  • round-robin over nodes
  • uses a single occupancy array
  • no heap, no threads, no timers

Implementations§

Source§

impl<C, T, const NODE_COUNT: usize, const EDGE_COUNT: usize> TestNoStdRuntime<C, T, NODE_COUNT, EDGE_COUNT>

Source

pub const fn new() -> Self

Construct with a pessimistic initial occupancy; init() will overwrite it.

Source

pub fn with_telemetry<F, R>(&mut self, f: F) -> Result<Option<R>, RuntimeError>
where F: FnOnce(&mut T) -> R,

Safely access telemetry by mutable reference, if it is present.

Returns:

  • Ok(Some(r)) if telemetry is present and f ran.
  • Ok(None) if telemetry is currently absent (e.g. not yet initialized).

This never panics and never moves telemetry out of the runtime.

Trait Implementations§

Source§

impl<C, T, const NODE_COUNT: usize, const EDGE_COUNT: usize> Default for TestNoStdRuntime<C, T, NODE_COUNT, EDGE_COUNT>

Source§

fn default() -> Self

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

impl<Graph, C, T, const NODE_COUNT: usize, const EDGE_COUNT: usize> LimenRuntime<Graph, NODE_COUNT, EDGE_COUNT> for TestNoStdRuntime<C, T, NODE_COUNT, EDGE_COUNT>
where Graph: GraphApi<NODE_COUNT, EDGE_COUNT>, C: PlatformClock + Sized, T: Telemetry + Sized,

Source§

type Clock = C

Clock abstraction stored by the runtime. Use () if not needed.
Source§

type Telemetry = T

Telemetry collector stored by the runtime. Use () if not needed.
Source§

type Error = RuntimeError

Error type produced by the runtime. Use core::convert::Infallible if none.
Source§

type StopHandle = RuntimeStopHandle

External stop handle type. Clone + Send + Sync + 'static. Only available under std.
Source§

fn init( &mut self, graph: &mut Graph, clock: Self::Clock, telemetry: Self::Telemetry, ) -> Result<(), Self::Error>

Initialize internal state and adopt the provided clock & telemetry.
Source§

fn reset(&mut self, graph: &Graph) -> Result<(), Self::Error>

Reset internal runtime state (keep graph/node state unless your policy requires otherwise).
Source§

fn request_stop(&mut self)

Request a cooperative stop.
Source§

fn is_stopping(&self) -> bool

Return true iff a stop has been requested.
Source§

fn occupancies(&self) -> &[EdgeOccupancy; EDGE_COUNT]

Borrow the runtime’s persistent edge-occupancy buffer.
Source§

fn step(&mut self, graph: &mut Graph) -> Result<bool, Self::Error>

Execute one scheduler tick. Return Ok(true) if more work remains, Ok(false) to stop.
Source§

fn stop_handle(&self) -> Option<Self::StopHandle>

Return an external stop handle, if the runtime supports it. Clone before calling run() to enable stopping from another thread.
Source§

fn run(&mut self, graph: &mut Graph) -> Result<(), Self::Error>

Drive the runtime until step() returns false or a stop is requested.

Auto Trait Implementations§

§

impl<C, T, const NODE_COUNT: usize, const EDGE_COUNT: usize> Freeze for TestNoStdRuntime<C, T, NODE_COUNT, EDGE_COUNT>
where C: Freeze, T: Freeze,

§

impl<C, T, const NODE_COUNT: usize, const EDGE_COUNT: usize> RefUnwindSafe for TestNoStdRuntime<C, T, NODE_COUNT, EDGE_COUNT>

§

impl<C, T, const NODE_COUNT: usize, const EDGE_COUNT: usize> Send for TestNoStdRuntime<C, T, NODE_COUNT, EDGE_COUNT>
where C: Send, T: Send,

§

impl<C, T, const NODE_COUNT: usize, const EDGE_COUNT: usize> Sync for TestNoStdRuntime<C, T, NODE_COUNT, EDGE_COUNT>
where C: Sync, T: Sync,

§

impl<C, T, const NODE_COUNT: usize, const EDGE_COUNT: usize> Unpin for TestNoStdRuntime<C, T, NODE_COUNT, EDGE_COUNT>
where C: Unpin, T: Unpin,

§

impl<C, T, const NODE_COUNT: usize, const EDGE_COUNT: usize> UnsafeUnpin for TestNoStdRuntime<C, T, NODE_COUNT, EDGE_COUNT>
where C: UnsafeUnpin, T: UnsafeUnpin,

§

impl<C, T, const NODE_COUNT: usize, const EDGE_COUNT: usize> UnwindSafe for TestNoStdRuntime<C, T, NODE_COUNT, EDGE_COUNT>
where C: UnwindSafe, T: UnwindSafe,

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