Skip to main content

ResourceSpec

Struct ResourceSpec 

Source
pub struct ResourceSpec {
    pub id: ResourceId,
    pub kind: String,
    pub label: String,
    pub presentation: Option<ResourcePresentation>,
    pub semantic_identity: Option<ResourceSemanticIdentity>,
    pub app_id: Option<String>,
    pub children: Vec<ResourceSpec>,
    pub actions: Vec<ActionSpec>,
    pub views: Vec<ResourceViewSpec>,
    pub personal: bool,
    pub workspace: Option<String>,
    pub resource_type: Option<ResourceType>,
}
Expand description

One open/presented resource and the actions it exports. Resources nest via children.

Fields§

§id: ResourceId§kind: String

A stable kind tag (e.g. "tube.video", "ebook.annotation"), shared with the global-search type registry for OS-wide enumeration.

§label: String

Human, localisable label shown in the palette.

§presentation: Option<ResourcePresentation>

Optional shell-rendered metadata used by system search and resource browsers. Invalid or oversized values are omitted at the boundary.

§semantic_identity: Option<ResourceSemanticIdentity>

Exact original typed identity retained before host namespacing.

§app_id: Option<String>

The app that publishes it, as the ActionKeys of its actions name it: the one whose resource this is, not the provider keeping it in a workspace. None for a resource published outside an app.

§children: Vec<ResourceSpec>§actions: Vec<ActionSpec>§views: Vec<ResourceViewSpec>

Explicit presentations of this resource. Actions remain invocation mechanisms; only entries in this collection are resource views.

§personal: bool

Whether the reading is the person’s own rather than everyone’s: their clipboard, their notifications. Only a program the session runs itself reads it; an installed app reads what its own records hold.

§workspace: Option<String>

The workspace that holds the record, when it is not the one the window publishing it is open in: a person’s profile record, held in their own workspace. That workspace decides the record’s changes; None is the window’s.

§resource_type: Option<ResourceType>

What it is, as people name it, when its type says (ResourceType).

Implementations§

Source§

impl ResourceSpec

Source

pub fn address_of(&self, action: &ActionSpec) -> ActionAddress

The address of action as this resource publishes it: what the API takes, what a window’s control bound to it says it does, and what the survey lists — one address, which neither the window’s composition moving the control nor the person’s language renaming it changes.

Source

pub fn app(&self) -> Option<&str>

The app that publishes it, as an ActionKey of one of its actions names it (Self::app_id).

Source

pub fn domain_name(&self) -> &str

The resource’s own id, not the transport alias a window published it under (Self::semantic_identity): what its app and the directory naming it offer it at, whatever alias the broker delivers it under.

Source

pub fn with_presentation(self, presentation: ResourcePresentation) -> Self

Source

pub fn with_type(self, resource_type: ResourceType) -> Self

Saying what it is, as people name it.

Source

pub fn with_action(self, action: ActionSpec) -> Self

Source

pub fn with_view(self, view: ResourceViewSpec) -> Self

Source

pub fn with_personal_reading(self) -> Self

Publish this resource’s reading to the session’s own programs alone: what the person’s state needs, when it is theirs and not an app’s.

Source

pub fn held_in(self, workspace: impl Into<String>) -> Self

The record is held in workspace rather than in the window’s (Self::workspace).

Source

pub fn retain_actions(&mut self, keep: impl FnMut(&ActionSpec) -> bool)

Keep the actions keep admits, and only the views still opened by one of them: a view whose open action is not offered cannot be offered either, and the action contract refuses the whole surface that carries one.

Source

pub fn with_child(self, child: ResourceSpec) -> Self

Source

pub fn listed_for_people(&self) -> bool

Whether a palette may list it: a titled resource that offers a person at least one action of its own. An untitled node, a control mirror, and a node left with only agent actions are all addressing machinery, and a list of what a person may act on never shows them.

Source

pub fn person_action_count(&self) -> usize

How many of its actions a person may take.

Source

pub fn open_action(&self) -> Option<&ActionSpec>

The action that presents it, when a person may take it: what a palette lists the resource for.

Source

pub fn with_children( self, children: impl IntoIterator<Item = ResourceSpec>, ) -> Self

Source

pub fn action_address(&self, action: &str) -> Option<ActionAddress>

The address of the action action this resource publishes, or None when it publishes none by that id. A caller holding a published resource (a survey’s, a search hit’s, a bound tree’s) addresses its actions from it rather than writing an address of its own, so an action the resource stopped publishing fails here, at the caller.

Trait Implementations§

Source§

impl Clone for ResourceSpec

Written out rather than derived: a derived clone is inlined into every app that copies a resource, this one is compiled once.

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 Exports for ResourceSpec

Source§

fn exported(&self) -> &ResourceSpec

The resource as it is published: its identity, kind, sharing and exported actions.

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