Skip to main content

ActionContract

Struct ActionContract 

pub struct ActionContract {
    pub availability: Availability,
    pub kind: ActionKind,
    pub field: Option<String>,
    pub risk: RiskLevel,
    pub confirmation: ConfirmationPolicy,
    pub retry: RetryPolicy,
    pub execution: ExecutionMode,
    pub result: ResultSpec,
    pub tags: Vec<String>,
    pub offload: Option<Offload>,
}
Expand description

Complete operational contract copied into every inert descriptor.

Fields§

§availability: Availability§kind: ActionKind

What the action is able to do: read, change only the document, or reach outside it. Whether Undo takes it back and whether it asks first follow from it. What a grant must allow is its need, which every door decides with the action’s place in the published tree: the kind, unless the action’s scope reaches nothing a workspace governs (Self::scoped).

§field: Option<String>

The one field of its resource the action writes, when it writes only one: the action sits below that field in the tree, so a grant on the field (commenting is writing comments) reaches it.

§risk: RiskLevel§confirmation: ConfirmationPolicy§retry: RetryPolicy§execution: ExecutionMode§result: ResultSpec§tags: Vec<String>§offload: Option<Offload>

The action is heavy enough to run on another of the invoker’s devices, and how: see Offload. None (the default) runs it where it is invoked, always.

Implementations§

§

impl ActionContract

pub fn need(&self) -> ActionNeed

What an invocation needs when its value does not say otherwise: its kind, scoped.

pub fn scoped(&self, need: ActionNeed) -> ActionNeed

The authority need asks of a workspace once this action’s scope is accounted for. The kind says what the action does (whether Undo takes it back, whether it asks first); the need says what a grant must allow, and the scope is where they part: a change of the person’s own record (OWN_RECORD_SCOPE) and an outside effect on the person’s own device (OWN_DEVICE_SCOPE, ATTENDED_TAG) reach nothing a workspace’s grants govern, so they need only what reading needs.

pub fn view() -> ActionContract

Safe defaults for a presentation-only operation.

pub fn live_view(item_schema: Value) -> ActionContract

A view whose result stays current (ExecutionMode::Live), each item matching item_schema.

pub const fn is_live(&self) -> bool

Whether the action’s result stays current (ExecutionMode::Live).

pub fn for_operation(operation: OperationKind) -> ActionContract

The defaults for an operation of operation’s kind: a view reads, a document operation changes only the document, an effect reaches outside it.

pub fn is_own_device(&self) -> bool

Whether the effect’s scope is the invoking person’s own device and nothing shared. See OWN_DEVICE_SCOPE.

pub fn is_own_record(&self) -> bool

Whether the action changes a record of the invoking person’s own. See OWN_RECORD_SCOPE.

pub fn set_own_record(&mut self)

Mark the action as carried out on a record of the invoking person’s own: it keeps its kind and needs only what reading needs. See OWN_RECORD_SCOPE.

pub fn is_attended(&self) -> bool

Whether the action needs its person attending. See ATTENDED_TAG.

pub fn runs_on_invokers_device(&self) -> bool

Whether the action acts on the device of whoever invokes it, so only the person at that device (and those acting for them) runs it: an effect of OWN_DEVICE_SCOPE or one its person attends (ATTENDED_TAG).

pub fn audience(&self) -> Audience

Who the action is listed for, as its tags record it. See Audience.

pub fn set_audience(&mut self, audience: Audience)

Record audience in the tags, replacing any audience before it.

pub fn reaches_people(&self) -> bool

Whether people’s listings offer it. See Audience::reaches_people.

pub fn reaches_agents(&self) -> bool

Whether agents’ listings offer it. See Audience::reaches_agents.

pub fn reads_document(&self) -> bool

Whether the action reads the open document’s first page. See DOCUMENT_READ_TAG.

pub fn opens_path(&self) -> bool

Whether the action opens the file its path names. See OPENS_PATH_TAG.

pub fn opened_extensions(&self) -> impl Iterator<Item = &str>

The file extensions an opens_path action is declared for; none means any file. See OPENS_PATH_EXTENSION_PREFIX.

pub fn carries_untrusted_content(&self) -> bool

Whether the action’s result carries content from outside the user’s own data. See UNTRUSTED_CONTENT_TAG.

pub fn can_be_undone(&self) -> bool

Whether the action, once taken, can be undone: the host’s undo reverts an Undoable change, and an outside one declared with its compensation (COMPENSATED_UNDO_TAG) is undone by queueing it. One that also loses what Undo cannot bring back (IRREVERSIBLE_TAG) cannot.

pub fn requires_confirmation(&self) -> bool

Whether an invocation of this action must be confirmed before it runs: its risk asks for it and Undo cannot take it back (RiskLevel::requires_confirmation_when).

pub fn settle_confirmation(&mut self)

Bring the declared policy in line with the risk and whether Undo takes the action back: a deletion Undo takes back asks nothing, one it cannot asks with a click. An explicit typed phrase, and the policy of any other risk, stay as declared. Every builder that changes the risk, the undo or the tags calls this, so the order they are called in never decides whether a person is asked.

The kind is read through settled_kind, so a deletion built before the kind that makes it undoable still ends up asking nothing, and one a declaration says reaches outside still asks.

pub fn settled_kind(&self) -> ActionKind

The kind this contract says the action is, where kind cannot say it alone: a change to its own document is undoable unless it keeps something Undo cannot bring back (IRREVERSIBLE_TAG), or unless it reaches outside and queues its compensation (COMPENSATED_UNDO_TAG).

pub fn deletion_kind(&self) -> ActionKind

The kind of a deletion, which has to say which it is: what its kind settles to, less where Undo cannot take the change back at all.

pub fn confirmation_depends_on_arguments(&self) -> bool

Whether confirmation depends on the invocation’s arguments. See ARGUMENT_RISK_TAG.

pub fn advertised_confirmation(&self) -> ConfirmationPolicy

The confirmation a caller that cannot classify arguments must assume: the declared policy, or ConfirmationPolicy::Confirm for an action whose risk depends on its arguments. A trust boundary that only sees this inert contract (the session broker) gates on it; the publishing host, which can classify, asks ActionSpec::confirmation_for_json.

pub fn asks_for_argument(&self, argument: Option<&str>) -> bool

Whether an invocation with argument asks the person an agent acts for, whatever their broader answers allow: it needs a confirmation (Self::confirmation_for_argument) or its person attending (Self::is_attended).

pub fn confirmation_for_argument( &self, argument: Option<&str>, ) -> ConfirmationPolicy

The confirmation an invocation with argument (the wire argument: typed JSON behind ARGUMENTS_JSON_PREFIX) needs, decided without the publishing app’s code: the declared policy; for a generic field edit, the edit itself read by tilo_action_policy::edits::field_edit_asks; for any other action whose risk depends on its arguments, Self::advertised_confirmation.

pub fn validate_declaration(&self) -> Vec<String>

Validate the contract as inert protocol data. This is intentionally usable at both publication ends: a well-behaved app checks before it sends, and the broker repeats the check at its trust boundary.

§

impl ActionContract

pub fn requirements(&self) -> Vec<ContextRequirement>

The context preconditions declared on this contract, in order.

pub fn is_participant_view(&self) -> bool

Whether this View contract changes only the invoking participant’s view (PARTICIPANT_VIEW_TAG).

Trait Implementations§

§

impl Clone for ActionContract

§

fn clone(&self) -> ActionContract

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
§

impl Debug for ActionContract

§

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

Formats the value using the given formatter. Read more
§

impl Default for ActionContract

§

fn default() -> ActionContract

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

impl<'de> Deserialize<'de> for ActionContract

§

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

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

impl PartialEq for ActionContract

§

fn eq(&self, other: &ActionContract) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl Serialize for ActionContract

§

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
§

impl Eq for ActionContract

§

impl StructuralPartialEq for ActionContract

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
§

impl<T> AnyEq for T
where T: Any + PartialEq,

§

fn equals(&self, other: &(dyn Any + 'static)) -> bool

§

fn as_any(&self) -> &(dyn Any + 'static)

§

impl<T> AsAny for T
where T: 'static,

§

fn as_any(&self) -> &(dyn Any + 'static)

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
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSend for T
where T: Any + Send,

§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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
§

impl<T> NoneValue for T
where T: Default,

§

type NoneType = T

§

fn null_value() -> T

The none-equivalent value.
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: 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
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: 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> 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>

§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

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

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> CommonTraits for T
where T: AsAny + Any + Debug + WasmNotSendSync,

Source§

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

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> Fruit for T
where T: Send + Downcast,

§

impl<T> MaybeSendSync for T
where T: Send + Sync + ?Sized,

§

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

§

impl<T> WasmNotSendSync for T

§

impl<T> WasmNotSync for T
where T: Sync,