#[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
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
InputClosed
An input will receive nothing further.
Fields
reason: RouteCloseReasonWhy it closed.
Stop
Finish up: the host is winding the operator down.
Fields
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).
Implementations§
Source§impl OpEvent
impl OpEvent
Sourcepub const fn input(&self) -> Option<&DataId>
pub const fn input(&self) -> Option<&DataId>
The input this event concerns, when it concerns one.
Sourcepub const fn is_terminal(&self) -> bool
pub const fn is_terminal(&self) -> bool
Whether this event means the operator should wind down.
Sourcepub fn payload_len(&self) -> usize
pub fn payload_len(&self) -> usize
The payload bytes this event carries, for bandwidth accounting.
Sourcepub fn from_node_event(event: &NodeEvent) -> Option<Self>
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());