Skip to main content

Module resource

Module resource 

Expand description

The nested Resource tree an app publishes, and the **ActionSpec**s each resource exports.

A ResourceSpec is something the app currently has open/presented (a playing video, an open book); resources nest — a video owns its comments, a book its annotations. Each exports ActionSpecs: the operations Ctrl+K offers for it.

The split that matters: ResourceSpec/ActionSpec is presentation — local, per-frame, with human labels and (for a prompted action) a closure. The EncodedAction an ActionSpec yields is the action — serializable, replayable. Presentation never crosses a boundary; only the action does.

§The typed projection

A spec also carries a serializable projection of itself: a typed params list and a builder that turns bound ActionArgs into that same EncodedAction. That is what lets a caller with no window enumerate the surface (see crate::wire) and invoke it by name — the presentation stays local, but a faithful description of it can now cross.

The projection is derived from the same closure the palette uses: immediate projects to zero parameters returning its pre-encoded action, and prompted_param projects to one required Text parameter, named for what it is, that calls the app’s closure. An affordance, its palette row, and an external invocation therefore run through one function and produce the same action.

typed constructs an action whose argument has a domain type (a number in 0..=1, a fixed set of filter names) instead of relying on a lenient prose parser.

Structs§

ActionBinding
Type-safe adapter from a control’s input value to an exported action.
ActionSpec
One action a resource exports to the palette: an ActionType bound to the Target it acts on. Small: the type is shared, so a resource of ten thousand items holds each of its types once.
ActionState
What an action’s row shows of the state the action acts on, beside its label: data, never drawing code. Every surface that lists the action (the palette, a menu, an agent’s listing) reads the same.
ActionType
What an action is, whichever resource offers it: its id, label, contract, parameters and builders. Held once per (resource type, action) and shared by every ActionSpec that binds it to a Target.
ContinuationKey
Collision-free, provider-defined identity for one continuation target or handler. Tuple components remain separate; callers never join or hash them.
ControlInvocation
A UI control’s inert request to invoke one advertised operation.
FlatAction
One (resource, action) pair produced by flatten, addressable by a composite key the palette uses as its row id.
ListedRow
One action as a person reads it in a list: what it does, and under it what it acts on.
Noun
What one of something is called and what several are, in a sentence: mailbox and mailboxes, person and people.
ResourceId
Stable identity of a resource within the publishing app instance (e.g. tube.video:dQw4w9WgXcQ, ebook.annotation:<uuid>).
ResourcePresentation
Bounded, declarative search presentation for a resource.
ResourceSemanticIdentity
Descriptive source-domain identity, independent of the live dispatch alias. This metadata grants no permission or authority.
ResourceSpec
One open/presented resource and the actions it exports. Resources nest via children.
ResourceType
What a resource is, in the words people use for it: its type’s noun, the name of the app whose type it is, and whether it is that app’s root. What search matches a query naming what something is (“my mails”, “notes”) against, rather than its title.
ResourceViewMountSpec
How a live resource-view provider accepts a compositor-owned mount.
ResourceViewRangeSpec
Explicit range-navigation binding. Offsets retain the reference’s Chars or Bytes unit; the app validates them against its current text before moving.
ResourceViewSpec
An explicit presentation of a resource, separate from the actions used to open or mount it.
RunBy
Where another provider runs an action a view offers (ActionSpec::run_by).
Target
What one ActionSpec acts on: the item its shared ActionType is bound to (a note’s path, a file’s id). An action type’s builders receive it, so the type is held once for every item that offers it. An action declared with its state captured in its builder has none.

Enums§

ActionBindingError
Failure to construct or emit a control binding.
ActionInput
How the palette collects an ActionSpec’s input when it is chosen.
Collects
What kind of thing an action’s one text argument names. Words are what the asker says outright; a content hash addresses bytes already in this machine’s blob store (nobody types one, it names something an earlier operation produced). Declared on the spec rather than inferred, so a caller with no screen can tell “give me a new name” from “give me the image to place”.
ContinuationArguments
ContinuationEvidence
ContinuationQuery
Readers
Who may read a resource’s reading.

Constants§

INVALID_ARGUMENTS_TYPE
Inert envelope produced when the legacy one-field palette cannot satisfy a typed contract. Hosts recognize it as a refusal; it is never registered or dispatched as an application operation.
KEY_SEP
Field separator inside a flattened composite key — a unit-separator control char never appears in a resource or action id.
NESTED_RESOURCE_FACET
The facet naming the nested resource an action was addressed through, when history names the enclosing resource whose action it is (ActionSpec::history_context).
PROMPTED_PARAM
The generic parameter name of an argument that is a bare value: an accessibility set-value, a content hash (ActionSpec::prompted_content), a wire InvokeArgument::Text before a descriptor says where it goes. An app’s own prompted action names its parameter (ActionSpec::prompted_param) and callers ask ActionSpec::prompt_param.

Functions§

flatten
Depth-first flatten of a resource forest into every exported action, parents before children — what the palette lists.
in_words
A declared name in words, lower case: TodoList and todo_list are todo list.
kind_mirrors_a_control
Whether kind names a control the window already draws, or an operation of the host it runs on: nodes published so a caller can address them, never something a person looks for in a list.
listed_for_people
Whether a resource of kind titled label is something a person looks for: titled, and the app’s own rather than a mirror of one of its controls or an operation of the host it runs on. Those are published to be addressed, never listed.
listed_row
The row for an action labelled label, which acts on the item named item (none for the app or document itself): the label alone as the title, the outcome in the person’s words, and the item’s name under it when it acts on one. An action’s description is written for agents and scripts (what it takes, what it answers) and is never the line under a person’s row; it still finds the row in a search. Never the label joined to the resource’s name, a kind of control (“— Focus”), an id or a separator glyph: every list of actions people see (an app’s palette, desktop search) builds its rows here.
listed_row_problems
What is wrong with how row reads, if anything: a raw id (a run of ten or more digits, a long hex string) anywhere, or in its label a separator glyph joining facts or a control’s own verb (“— Focus”). Empty for a row that reads as an outcome in the person’s words. The line under the label may quote the person’s own content (an article’s title), so only ids are looked for there. Every list of actions people see is held to this (listed_row builds rows that pass).
plural
What several of noun are called, as English writes most: notes, entries, boxes. A y after a consonant is ies; s, x, z, ch and sh take es; anything else takes s.
singular
What one of several called noun is called, as English writes most: notes is a note, entries an entry, boxes a box. The reverse of plural for the words it makes, and of what a Collection<…> field is named (videos, whose items are a video); a noun already singular reads as it is (history), and one no rule derives keeps its name.
sole_text_argument

Type Aliases§

ArgsBuilder
Builds an action’s encoded form from arguments already bound against its declared params.
NeedClassifier
Classifies what one invocation is from its bound arguments. The Target is that of the spec being invoked.
RiskClassifier
Classifies the risk of one invocation from its bound arguments. The Target is that of the spec being invoked.
UndoClassifier
Decides from one invocation’s bound arguments whether Undo takes it back.