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§
- Action
Binding - Type-safe adapter from a control’s input value to an exported action.
- Action
Spec - One action a resource exports to the palette: an
ActionTypebound to theTargetit acts on. Small: the type is shared, so a resource of ten thousand items holds each of its types once. - Action
State - 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.
- Action
Type - 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
ActionSpecthat binds it to aTarget. - Continuation
Key - Collision-free, provider-defined identity for one continuation target or handler. Tuple components remain separate; callers never join or hash them.
- Control
Invocation - A UI control’s inert request to invoke one advertised operation.
- Flat
Action - One (resource, action) pair produced by
flatten, addressable by a compositekeythe palette uses as its row id. - Listed
Row - 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:
mailboxandmailboxes,personandpeople. - Resource
Id - Stable identity of a resource within the publishing app instance
(e.g.
tube.video:dQw4w9WgXcQ,ebook.annotation:<uuid>). - Resource
Presentation - Bounded, declarative search presentation for a resource.
- Resource
Semantic Identity - Descriptive source-domain identity, independent of the live dispatch alias. This metadata grants no permission or authority.
- Resource
Spec - One open/presented resource and the actions it exports. Resources
nest via
children. - Resource
Type - 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.
- Resource
View Mount Spec - How a live resource-view provider accepts a compositor-owned mount.
- Resource
View Range Spec - Explicit range-navigation binding. Offsets retain the reference’s Chars or Bytes unit; the app validates them against its current text before moving.
- Resource
View Spec - 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
ActionSpecacts on: the item its sharedActionTypeis 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§
- Action
Binding Error - Failure to construct or emit a control binding.
- Action
Input - 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”.
- Continuation
Arguments - Continuation
Evidence - Continuation
Query - 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 wireInvokeArgument::Textbefore a descriptor says where it goes. An app’s own prompted action names its parameter (ActionSpec::prompted_param) and callers askActionSpec::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:
TodoListandtodo_listaretodo list. - kind_
mirrors_ a_ control - Whether
kindnames 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
kindtitledlabelis 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 nameditem(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
rowreads, 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_rowbuilds rows that pass). - plural
- What several of
nounare called, as English writes most:notes,entries,boxes. Ayafter a consonant isies;s,x,z,chandshtakees; anything else takess. - singular
- What one of several called
nounis called, as English writes most:notesis anote,entriesanentry,boxesabox. The reverse ofpluralfor the words it makes, and of what aCollection<…>field is named (videos, whose items are avideo); a noun already singular reads as it is (history), and one no rule derives keeps its name. - sole_
text_ argument
Type Aliases§
- Args
Builder - Builds an action’s encoded form from arguments already bound against its
declared
params. - Need
Classifier - Classifies what one invocation is from its bound arguments.
The
Targetis that of the spec being invoked. - Risk
Classifier - Classifies the risk of one invocation from its bound arguments.
The
Targetis that of the spec being invoked. - Undo
Classifier - Decides from one invocation’s bound arguments whether Undo takes it back.