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: ActionKindWhat 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§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
impl ActionContract
Sourcepub fn declares(&self, provider: &str, address: &ActionAddress) -> bool
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).
Sourcepub fn need(&self) -> ActionNeed
pub fn need(&self) -> ActionNeed
What an invocation needs when its value does not say otherwise: its
kind, scoped.
Sourcepub fn scoped(&self, need: ActionNeed) -> ActionNeed
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.
Sourcepub fn live_view(item_schema: Value) -> Self
pub fn live_view(item_schema: Value) -> Self
A view whose result stays current (ExecutionMode::Live), each
item matching item_schema.
Sourcepub const fn is_live(&self) -> bool
pub const fn is_live(&self) -> bool
Whether the action’s result stays current (ExecutionMode::Live).
Sourcepub fn for_operation(operation: OperationKind) -> Self
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.
Sourcepub fn is_own_device(&self) -> bool
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.
Sourcepub fn is_attended(&self) -> bool
pub fn is_attended(&self) -> bool
Whether the action needs its person attending. See ATTENDED_TAG.
Sourcepub fn runs_on_invokers_device(&self) -> bool
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).
Sourcepub fn only_shows(&self) -> bool
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.
Sourcepub fn root_only(&self) -> bool
pub fn root_only(&self) -> bool
Whether only the person’s root signs it (ROOT_ONLY_TAG).
Sourcepub fn answers_a_secret(&self) -> bool
pub fn answers_a_secret(&self) -> bool
Whether its answer is a secret, handed over once and kept nowhere (SECRET_ANSWER_TAG).
Sourcepub fn shows_a_place(&self) -> bool
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).
Sourcepub fn screen() -> Self
pub fn screen() -> Self
Safe defaults for an effect that only changes what is on the screen it
is invoked on (Self::only_shows).
Sourcepub fn audience(&self) -> Audience
pub fn audience(&self) -> Audience
Who the action is listed for, as its tags record it. See Audience.
Sourcepub fn set_audience(&mut self, audience: Audience)
pub fn set_audience(&mut self, audience: Audience)
Record audience in the tags, replacing any audience before it.
Sourcepub fn reaches_people(&self) -> bool
pub fn reaches_people(&self) -> bool
Whether people’s listings offer it. See Audience::reaches_people.
Sourcepub fn reaches_agents(&self) -> bool
pub fn reaches_agents(&self) -> bool
Whether agents’ listings offer it. See Audience::reaches_agents.
Sourcepub fn needs_an_item(&self) -> bool
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.
Sourcepub fn offered_to_people(&self) -> bool
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.
Sourcepub fn a_person_can_take_now(&self) -> bool
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.
Sourcepub fn offered_to_agents(&self) -> bool
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.
Sourcepub fn reads_document(&self) -> bool
pub fn reads_document(&self) -> bool
Whether the action reads the open document’s first page. See
DOCUMENT_READ_TAG.
Sourcepub fn reads_resource(&self) -> bool
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).
Sourcepub fn discloses_resource(&self) -> bool
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).
Sourcepub fn disclosure_rank(&self) -> u8
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.
Sourcepub fn opens_path(&self) -> bool
pub fn opens_path(&self) -> bool
Whether the action opens the file its path names. See
OPENS_PATH_TAG.
Sourcepub fn opened_extensions(&self) -> impl Iterator<Item = &str>
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.
Sourcepub fn carries_untrusted_content(&self) -> bool
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.
Sourcepub fn carries_actions(&self) -> bool
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.
Sourcepub fn outside_capabilities(&self) -> impl Iterator<Item = &str>
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.
Sourcepub fn can_be_undone(&self) -> bool
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.
Sourcepub fn requires_confirmation(&self) -> bool
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).
Sourcepub fn settle_confirmation(&mut self)
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.
Sourcepub fn settled_kind(&self) -> ActionKind
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).
Sourcepub fn deletion_kind(&self) -> ActionKind
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.
Sourcepub fn confirmation_depends_on_arguments(&self) -> bool
pub fn confirmation_depends_on_arguments(&self) -> bool
Whether confirmation depends on the invocation’s arguments. See
ARGUMENT_RISK_TAG.
Sourcepub fn advertised_confirmation(&self) -> ConfirmationPolicy
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.
Sourcepub fn asks_for_argument(&self, argument: Option<&str>) -> bool
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).
Sourcepub fn confirmation_for_argument(
&self,
argument: Option<&str>,
) -> ConfirmationPolicy
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.
Sourcepub fn validate_declaration(&self) -> Vec<String>
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
impl ActionContract
Sourcepub fn requirements(&self) -> Vec<ContextRequirement>
pub fn requirements(&self) -> Vec<ContextRequirement>
The context preconditions declared on this contract, in order.
Sourcepub fn is_presence_view(&self) -> bool
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
impl Clone for ActionContract
Source§impl Debug for ActionContract
impl Debug for ActionContract
Source§impl Default for ActionContract
impl Default for ActionContract
Source§impl<'de> Deserialize<'de> for ActionContract
impl<'de> Deserialize<'de> for ActionContract
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for ActionContract
Source§impl PartialEq for ActionContract
impl PartialEq for ActionContract
Source§impl Serialize for ActionContract
impl Serialize for ActionContract
impl StructuralPartialEq for ActionContract
Auto Trait Implementations§
impl Forget for ActionContract
impl Freeze for ActionContract
impl Move for ActionContract
impl RefUnwindSafe for ActionContract
impl Send for ActionContract
impl Sync for ActionContract
impl Unpin for ActionContract
impl UnsafeUnpin for ActionContract
impl UnwindSafe for ActionContract
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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