Skip to main content

OpEvent

Enum OpEvent 

Source
#[non_exhaustive]
pub enum OpEvent { Input { id: DataId, source: PortRef, metadata: Metadata, payload: Vec<u8>, }, InputClosed { id: DataId, source: PortRef, reason: RouteCloseReason, }, Stop { cause: StopCause, grace: Option<DurationMs>, }, Reload, ParamUpdate { scope: ParamScope, key: ParamKey, value: Parameter, }, }
Expand description

One event delivered to an crate::Operator (blueprint §9.3).

#[non_exhaustive]: new variants may join at the tail as the runtime’s operator-hosting story grows (blueprint §3.4’s append-only rule).

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Input

One message for one of the operator’s inputs.

The payload is raw bytes — an Arrow IPC stream (blueprint §6.1) — exactly as it rides astrs_wire::NodeEvent::Input; decoding into a typed astrs_data::AstrsMessage is the operator’s own business.

Fields

§id: DataId

The input this message arrived on.

§source: PortRef

The producer port it came from.

§metadata: Metadata

The metadata riding beside the payload.

§payload: Vec<u8>

The payload bytes.

§

InputClosed

An input will receive nothing further.

Fields

§id: DataId

The input that closed.

§source: PortRef

The producer port that stopped.

§reason: RouteCloseReason

Why it closed.

§

Stop

Finish up: the host is winding the operator down.

Fields

§cause: StopCause

Why the operator is being stopped.

§grace: Option<DurationMs>

How long it has before it is dropped without a clean exit.

§

Reload

Reset the operator’s own state (blueprint §9.3).

Unlike astrs_wire::NodeEvent::Reload, this carries no operator selector or path: by the time the host delivers this event on a specific operator’s channel, the routing question is already answered, and dylib hot-reload (the case path exists for) is deferred to 0.2 (blueprint §9.3, §22) — there is no artefact to name yet.

§

ParamUpdate

A parameter this operator reads was written (blueprint §17 param set).

Fields

§scope: ParamScope

The scope it was written in.

§key: ParamKey

The key.

§value: Parameter

The new value.

Implementations§

Source§

impl OpEvent

Source

pub const fn input(&self) -> Option<&DataId>

The input this event concerns, when it concerns one.

Source

pub const fn is_input(&self) -> bool

Whether this event delivers data.

Source

pub const fn is_terminal(&self) -> bool

Whether this event means the operator should wind down.

Source

pub fn payload_len(&self) -> usize

The payload bytes this event carries, for bandwidth accounting.

Source

pub fn from_node_event(event: &NodeEvent) -> Option<Self>

Narrows a node-level NodeEvent to the operator-level event it corresponds to, or None when the node event has no operator-level meaning (route-plane changes, peer lifecycle, extension-table traffic and registration — all handled by the node host itself, never surfaced to an operator).

This is the bridge astrs-runtime uses to fan a node’s event stream out to each hosted operator’s own channel (blueprint §9.3: “each operator runs on its own thread over a bounded channel”).

§Examples
use astrs_operator_api::OpEvent;
use astrs_wire::{DataId, Metadata, NodeEvent};
use astrs_time::HlcTimestamp;

let node_event = NodeEvent::Input {
    id: DataId::new("frames").unwrap(),
    source: "camera/image".parse().unwrap(),
    metadata: Metadata::new(HlcTimestamp::EPOCH),
    payload: vec![1, 2, 3],
};
assert!(OpEvent::from_node_event(&node_event).is_some());
assert!(OpEvent::from_node_event(&NodeEvent::AllInputsClosed).is_none());

Trait Implementations§

Source§

impl Clone for OpEvent

Source§

fn clone(&self) -> Self

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

Source§

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

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

impl PartialEq for OpEvent

Source§

fn eq(&self, other: &Self) -> 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 OpEvent

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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

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

Source§

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

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 = !

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

fn try_from(value: U) -> Result<T, !>

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