Skip to main content

Signal

Struct Signal 

Source
pub struct Signal {
    pub kind: SignalKind,
    pub scope: SignalScope,
    pub source: Principal,
}
Expand description

A control signal message.

Signals are used for immediate control operations like stopping or canceling work in progress.

§Permission Checking

The signal itself does not contain permission information. Permission is determined by:

  1. The runtime layer’s Session that sends the signal
  2. The SignalScope being targeted
  3. The policy configured in the EventBus

§Why No Default?

DO NOT implement Default for Signal.

A signal requires:

There is no sensible default for any of these.

§Example

use orcs_event::{Signal, SignalKind};
use orcs_types::{Principal, ChannelId, PrincipalId, SignalScope};

let principal = Principal::User(PrincipalId::new());
let channel = ChannelId::new();

let signal = Signal::new(
    SignalKind::Cancel,
    SignalScope::Channel(channel),
    principal,
);

Fields§

§kind: SignalKind

What type of signal.

§scope: SignalScope

What scope is affected.

§source: Principal

Who is sending the signal.

Implementations§

Source§

impl Signal

Source

pub fn new(kind: SignalKind, scope: SignalScope, source: Principal) -> Signal

Creates a new signal.

§Arguments
  • kind - The type of signal
  • scope - What scope is affected
  • source - Who is sending the signal
§Note

This does not check permissions. Permission checking is done at the EventBus layer using the Session’s privilege.

Source

pub fn veto(source: Principal) -> Signal

Creates a Veto (global stop) signal.

Requires elevated privilege to execute.

§Arguments
  • source - Who is sending the signal
§Example
use orcs_event::Signal;
use orcs_types::{Principal, PrincipalId};

let principal = Principal::User(PrincipalId::new());
let signal = Signal::veto(principal);

assert!(signal.is_veto());
assert!(signal.is_global());
Source

pub fn cancel(channel: ChannelId, source: Principal) -> Signal

Creates a Cancel signal for a specific channel.

§Arguments
  • channel - The channel to cancel
  • source - Who is sending the signal
§Example
use orcs_event::Signal;
use orcs_types::{Principal, ChannelId, PrincipalId};

let principal = Principal::User(PrincipalId::new());
let channel = ChannelId::new();
let signal = Signal::cancel(channel, principal);

assert!(!signal.is_veto());
assert!(signal.affects_channel(channel));
Source

pub fn is_veto(&self) -> bool

Returns true if this is a Veto signal.

Source

pub fn is_global(&self) -> bool

Returns true if this signal has Global scope.

Source

pub fn affects_channel(&self, channel: ChannelId) -> bool

Returns true if this signal affects the given channel.

Global signals affect all channels.

Source

pub fn pause(channel: ChannelId, source: Principal) -> Signal

Creates a Pause signal for a specific channel.

§Arguments
  • channel - The channel to pause
  • source - Who is sending the signal
Source

pub fn resume(channel: ChannelId, source: Principal) -> Signal

Creates a Resume signal for a specific channel.

§Arguments
  • channel - The channel to resume
  • source - Who is sending the signal
Source

pub fn steer( channel: ChannelId, message: impl Into<String>, source: Principal, ) -> Signal

Creates a Steer signal for a specific channel.

§Arguments
  • channel - The channel to steer
  • message - Instruction for how to change direction
  • source - Who is sending the signal
Source

pub fn approve(approval_id: impl Into<String>, source: Principal) -> Signal

Creates an Approve signal for a pending HIL request.

§Arguments
  • approval_id - ID of the approval request to approve
  • source - Who is sending the signal (typically Human)
Source

pub fn reject( approval_id: impl Into<String>, reason: Option<String>, source: Principal, ) -> Signal

Creates a Reject signal for a pending HIL request.

§Arguments
  • approval_id - ID of the approval request to reject
  • reason - Optional reason for rejection
  • source - Who is sending the signal (typically Human)
Source

pub fn is_pause(&self) -> bool

Returns true if this is a Pause signal.

Source

pub fn is_resume(&self) -> bool

Returns true if this is a Resume signal.

Source

pub fn is_approve(&self) -> bool

Returns true if this is an Approve signal.

Source

pub fn is_reject(&self) -> bool

Returns true if this is a Reject signal.

Source

pub fn is_modify(&self) -> bool

Returns true if this is a Modify signal.

Source

pub fn is_hil_response(&self) -> bool

Returns true if this is a HIL response signal (Approve, Reject, or Modify).

Source

pub fn modify( approval_id: impl Into<String>, modified_payload: Value, source: Principal, ) -> Signal

Creates a Modify signal for a pending HIL request.

Approves the request but with modified parameters.

§Arguments
  • approval_id - ID of the approval request to modify
  • modified_payload - Modified payload to use instead of original
  • source - Who is sending the signal (typically Human)

Trait Implementations§

Source§

impl Clone for Signal

Source§

fn clone(&self) -> Signal

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 Signal

Source§

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

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

impl<'de> Deserialize<'de> for Signal

Source§

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

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

impl Serialize for Signal

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> MaybeSend for T
where T: Send,

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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 = !

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

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more