pub trait SignalReceiver {
// Required methods
fn on_signal(&mut self, signal: &Signal) -> SignalResponse;
fn abort(&mut self);
}Expand description
Signal receiver for human control.
All entities must respond to signals because “Human is Superpower” - humans can always interrupt.
§Signal Priority
Signals are the highest priority messages in ORCS. They must be processed immediately, even during active work.
§Required Responses
| Signal | Expected Response |
|---|---|
| Veto | Abort + call abort() |
| Cancel (in scope) | Abort or Handled |
| Cancel (out of scope) | Ignored |
| Pause | Handled + change state |
| Resume | Handled + resume work |
§Example
use orcs_component::{SignalReceiver, Status};
use orcs_event::{Signal, SignalResponse};
struct Worker {
status: Status,
}
impl SignalReceiver for Worker {
fn on_signal(&mut self, signal: &Signal) -> SignalResponse {
if signal.is_veto() {
self.abort();
SignalResponse::Abort
} else if signal.is_global() {
// Global signals we can't handle
SignalResponse::Ignored
} else {
SignalResponse::Handled
}
}
fn abort(&mut self) {
self.status = Status::Aborted;
// Clean up resources, cancel pending work, etc.
}
}Required Methods§
Sourcefn on_signal(&mut self, signal: &Signal) -> SignalResponse
fn on_signal(&mut self, signal: &Signal) -> SignalResponse
Handle an incoming signal.
Called for every signal that reaches this entity. Must check signal scope to determine relevance.
§Returns
Handled: Signal was processedIgnored: Signal not relevant (out of scope)Abort: Entity is stopping due to signal