Skip to main content

ActionContract

Struct ActionContract 

Source
pub struct ActionContract {
Show 16 fields 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>, pub step: Option<StepKind>, pub creates: Option<String>, pub item: Option<String>, pub shows: Vec<Shown>, pub takes: Vec<Take>, pub effects: Vec<ActionEffect>,
}
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 API decides with the action’s place in the published tree: the kind, unless the action’s scope reaches nothing a workspace decides (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.

§step: Option<StepKind>

The kind of step it takes, as its declaration names it (crate::StepKind): what presence says in the reader’s language (“Writing in Trip plan”, “Schreibt in Trip plan”). None for an action whose declaration names none, whose step reads as the part of the record it acts on.

§creates: Option<String>

The collection of its resource a create adds to (writes = issues), when its declaration names one: what it makes, which presence says by that collection’s own noun (“Creating an issue in Issues”). None for an action that makes nothing, or whose declaration names no collection.

§item: Option<String>

The collection whose item the action acts on, when its declaration says it acts on one (item = issues) and no item is bound to it yet: “Open issue” on the tracker itself. It is offered only where an item is in hand, bound on that item, so a listing that holds none (a palette with nothing selected, an agent’s listing of the tracker) leaves it out (Self::needs_an_item). A caller that names the action and its item still invokes it here. None for an action that needs no item, or one already bound to its item.

§shows: Vec<Shown>

The arguments the person reads before answering, when the action asks first (ConfirmationPolicy::Confirm): what admission shows on its ask, read from the call itself.

§takes: Vec<Take>

What the person types where they answer its ask, in order: a site’s user name and password, a passphrase. It reaches the action with their approve (crate::remote::asked::Approval::typed), never as an argument of the call, so a secret is in no record of it.

§effects: Vec<ActionEffect>

What it writes beside its own resource, each as the app, kind and verb of the step it takes there (crate::ActionEffect). What a caller reads to know what the action changes; what a device reading such a record checks to admit a step the call itself does not name; and what a call its app makes for one of its invocations is held to: a call to an action named here is covered by the yes that invocation was given and asks nobody again, a call to any other action asks as any call does. Never from the call, always from this declaration.

Implementations§

Source§

impl ActionContract

Source

pub fn declares(&self, provider: &str, address: &ActionAddress) -> bool

Whether it declares the call of provider’s address as one of its own steps (Self::effects).

Source

pub fn need(&self) -> ActionNeed

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

Source

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: an outside effect on the person’s own device (OWN_DEVICE_SCOPE, ATTENDED_TAG) reaches nothing a workspace’s grants cover, so it needs only what reading needs. Every change of a record is the workspace’s to decide.

Source

pub fn view() -> Self

Safe defaults for a presentation-only operation.

Source

pub fn live_view(item_schema: Value) -> Self

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

Source

pub const fn is_live(&self) -> bool

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

Source

pub fn for_operation(operation: OperationKind) -> Self

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

Source

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.

Source

pub fn is_attended(&self) -> bool

Whether the action needs its person attending. See ATTENDED_TAG.

Source

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

Source

pub fn only_shows(&self) -> bool

Whether an effect under this contract only changes what is on the screen it is invoked on, as its app declares (SCREEN_TAG): a form it opens, a panel or a place it shows. Only the person at that screen invokes it; for anyone else it would move their window and tell the caller nothing. Nothing else about the contract decides it: an effect that reads and answers nothing may still write, and is decided as what it declares.

Source

pub fn root_only(&self) -> bool

Whether only the person’s root signs it (ROOT_ONLY_TAG).

Source

pub fn answers_a_secret(&self) -> bool

Whether its answer is a secret, handed over once and kept nowhere (SECRET_ANSWER_TAG).

Source

pub fn shows_a_place(&self) -> bool

Whether the effect shows the row it is offered on, answered against its caller’s view (SCREEN_PLACE_TAG).

Source

pub fn screen() -> Self

Safe defaults for an effect that only changes what is on the screen it is invoked on (Self::only_shows).

Source

pub fn audience(&self) -> Audience

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

Source

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

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

Source

pub fn reaches_people(&self) -> bool

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

Source

pub fn reaches_agents(&self) -> bool

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

Source

pub fn needs_an_item(&self) -> bool

Whether it acts on an item it has not been given (Self::item): what only a place holding an item offers.

Source

pub fn offered_to_people(&self) -> bool

Whether a listing that holds no item offers it to a person: one for people that needs no item (Self::needs_an_item). The palette with nothing selected, a window’s controls and a search list this.

Source

pub fn a_person_can_take_now(&self) -> bool

Whether a person may take it from a list now: offered to people (Self::offered_to_people) and with something to act on in the window’s state. One that can only say why it cannot run (an event’s Invite with no event selected) takes no row: the person who typed its name meant the thing that works.

Source

pub fn offered_to_agents(&self) -> bool

Self::offered_to_people for agents: what an agent’s listing of a resource offers it, an action that needs an item being offered on the item.

Source

pub fn reads_document(&self) -> bool

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

Source

pub fn reads_resource(&self) -> bool

Whether the action reads what its record holds and moves nothing: a document read (DOCUMENT_READ_TAG) or another read of the record’s state (RESOURCE_READ_TAG).

Source

pub fn discloses_resource(&self) -> bool

Whether a view under this contract shows its resource to callers other than its publisher: a read of the record (Self::reads_resource) or the caller’s own presence view. Any other view changes only what its caller sees, and keeps the resource it alone discloses private (the action directory’s disclosure, agent_disclosure).

Source

pub fn disclosure_rank(&self) -> u8

Which of a resource’s views the action directory discloses it through, lowest first and the first of equals: a document read, then another read of the record, then any other view.

Source

pub fn opens_path(&self) -> bool

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

Source

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.

Source

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.

Source

pub fn carries_actions(&self) -> bool

Whether the action carries its resource’s other actions and is no verb of its own. See CARRIER_TAG.

Source

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

The outside capabilities the action hands an effect to (youtube.search), as its tags record them. See OUTSIDE_CAPABILITY_PREFIX.

Source

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.

Source

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

Source

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.

Source

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

Source

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.

Source

pub fn confirmation_depends_on_arguments(&self) -> bool

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

Source

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) waits for it; the publishing host, which can classify, asks ActionSpec::confirmation_for_json.

Source

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

Source

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.

Source

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.

Source§

impl ActionContract

Source

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

The context preconditions declared on this contract, in order.

Source

pub fn is_presence_view(&self) -> bool

Whether this View contract changes only the invoking presence’s view (PRESENCE_VIEW_TAG).

Trait Implementations§

Source§

impl Clone for ActionContract

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 ActionContract

Source§

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

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

impl Default for ActionContract

Source§

fn default() -> Self

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

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

Source§

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

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

impl Eq for ActionContract

Source§

impl PartialEq for ActionContract

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 Serialize for ActionContract

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

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

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