ControllerCtx

Struct ControllerCtx 

Source
#[non_exhaustive]
pub struct ControllerCtx { pub op_name: String, pub op_dir: PathBuf, pub dt_ns: u32, pub timeout_to_operating_ns: u32, pub binding_timeout_ms: u16, pub configuring_timeout_ms: u16, pub peripheral_loss_of_contact_limit: u16, pub controller_loss_of_contact_limit: u16, pub termination_criteria: Vec<Termination>, pub loss_of_contact_policy: LossOfContactPolicy, pub user_ctx: BTreeMap<String, String>, pub user_channels: Arc<RwLock<BTreeMap<String, Channel>>>, }
Expand description

Operation context, provided to appendages during init

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§op_name: String

A name for this controller op, which will be used as the name of the file/table/bucket/etc of each data dispatcher and must be compatible with that use.

§op_dir: PathBuf

A directory to find file inputs and place outputs.

§dt_ns: u32

Control cycle period in nanoseconds

§timeout_to_operating_ns: u32

Delay from end of configuration window after which the peripherals time out to the Operating state

§binding_timeout_ms: u16

Duration to wait for responses to binding

§configuring_timeout_ms: u16

Duration for peripherals to wait to receive configuration after being bound

§peripheral_loss_of_contact_limit: u16

Number of consecutive missed control inputs after which the peripheral should assume contact has been lost, de-energize their outputs, and wait to bind a controller again.

§controller_loss_of_contact_limit: u16

Number of consecutive missed responses from a peripheral after which the controller should assume contact has been lost

§termination_criteria: Vec<Termination>

A set of conditions for exiting the control loop, to be checked at each cycle

§loss_of_contact_policy: LossOfContactPolicy

Response to losing contact with a peripheral

§user_ctx: BTreeMap<String, String>

An escape hatch for sideloading user context (likely json-encoded) that is not yet implemented as a standalone field.

§user_channels: Arc<RwLock<BTreeMap<String, Channel>>>

An escape hatch for sideloading communication between appendages. Each channel is a bidirectional MPMC message pipe.

Because bidirectional channels may not close until the program terminates on its own, the status of these channels should not be used to indicate when a freerunning thread should terminate, as this will often result in a resource leak.

Implementations§

Source§

impl ControllerCtx

Source

pub fn source_endpoint(&self, channel_name: &str) -> Endpoint

Get a handle to a source endpoint tx/rx pair for the channel, creating the channel if it does not exist.

Examples found in repository?
examples/sideloading.rs (line 107)
105    fn init(&mut self, ctx: ControllerCtx, _input_indices: Vec<usize>, output_range: Range<usize>) {
106        self.output_index = output_range.clone().next().unwrap();
107        self.endpoint = ctx.source_endpoint(&self.channel_name);
108        self.prefix = ctx.user_ctx.get("speaker_prefix").unwrap().to_owned();
109    }
Source

pub fn sink_endpoint(&self, channel_name: &str) -> Endpoint

Get a handle to a sink endpoint tx/rx pair for the channel, creating the channel if it does not exist.

Examples found in repository?
examples/sideloading.rs (line 182)
180    fn init(&mut self, ctx: ControllerCtx, _input_indices: Vec<usize>, output_range: Range<usize>) {
181        self.output_index = output_range.clone().next().unwrap();
182        self.endpoint = ctx.sink_endpoint(&self.channel_name);
183    }

Trait Implementations§

Source§

impl Clone for ControllerCtx

Source§

fn clone(&self) -> ControllerCtx

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 Debug for ControllerCtx

Source§

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

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

impl Default for ControllerCtx

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for ControllerCtx

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for ControllerCtx

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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.

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

Source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>

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

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

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,