pub struct Tree<P> { /* private fields */ }Expand description
The published tree of one workspace as one caller walks it, over P.
It keeps what it read for the calls after: the directory levels of each provider, the
app each name means and the paths its listings resolved, each bounded. What it kept is
checked by the provider when a call reaches it, so a stale one costs a refusal, never a
wrong write; a refusal drops what was kept of that app (Self::forget_app).
Implementations§
Source§impl<P: ActionProvider + Sync + Clone + Send + 'static> Tree<P>
impl<P: ActionProvider + Sync + Clone + Send + 'static> Tree<P>
Sourcepub async fn level_reaching(
&self,
provider: &str,
parent: &str,
level: Level,
children: usize,
) -> Result<Level, Unresolved>
pub async fn level_reaching( &self, provider: &str, parent: &str, level: Level, children: usize, ) -> Result<Level, Unresolved>
level, read on until it holds more than children resources or
the directory ends: what a listing paging past the first bounded
read needs, so every resource a directory holds is reachable.
Sourcepub async fn level_holding(
&self,
provider: &str,
parent: &str,
levels: &mut Levels,
find: impl Fn(&Level) -> Result<Option<Node>, Unresolved> + Send,
) -> Result<(Option<Node>, Level), Unresolved>
pub async fn level_holding( &self, provider: &str, parent: &str, levels: &mut Levels, find: impl Fn(&Level) -> Result<Option<Node>, Unresolved> + Send, ) -> Result<(Option<Node>, Level), Unresolved>
The directory level under parent, and the resource find picks out of it: the
level is read on past its bound until find picks one or the directory ends. A read
that names one resource so finds it wherever it falls in the directory, where a level
read only to its bound would say a resource past it is not there. find picks among
Level::whole_children, so the resource it finds has all its actions. The level,
as far as it was read, is kept in levels.
Sourcepub async fn level_from(
&self,
provider: &str,
parent: &str,
mark: PageMark,
children: usize,
) -> Result<Option<Level>, Unresolved>
pub async fn level_from( &self, provider: &str, parent: &str, mark: PageMark, children: usize, ) -> Result<Option<Level>, Unresolved>
The directory under parent from the page mark names on, until it
holds more than children resources or ends.
A directory that moved on since mark was read is read on from the same row at the
revision it stands at now, as often as it moves on meanwhile ([RESUMES]): writes
beside a listing (an import’s) move a directory on between every two pages of it, and
read again from its first page, a listing of thousands never got back to where it
stood before the next write, and answered pages of nothing while its cursor went on.
A provider whose cursor does not carry over to another revision refuses it again, and
the read is None as the directory moved on.
Sourcepub async fn read_level(
&self,
provider: &str,
parent: &str,
from: Option<Level>,
reach: usize,
) -> Result<Option<Level>, Unresolved>
pub async fn read_level( &self, provider: &str, parent: &str, from: Option<Level>, reach: usize, ) -> Result<Option<Level>, Unresolved>
Up to LEVEL_PAGES pages of the directory under parent, from
the start or on from where from stopped, and no page past the
reachth resource while fewer would not do: a listing asks for the
resources its page holds, not a fixed stretch of the directory. It
starts again from the first page while the directory moves on between
pages or the app cannot read it.
Sourcepub async fn app_children(
&self,
provider: &str,
levels: &mut Levels,
) -> Result<Level, Unresolved>
pub async fn app_children( &self, provider: &str, levels: &mut Levels, ) -> Result<Level, Unresolved>
The resources an app’s path starts from: its top-level resources and
the resources inside its containers (a notebook’s pages are the app’s
own), with the containers’ own actions (notes#new-page). A root
resource’s actions are the app’s too, each under the root it is
published on (notes/Notes#new_note). A chain among them holds the
app’s items: it is listed first, with the items it holds, and its
actions are the app’s before any other’s (notes#new_note).
Sourcepub async fn app_children_listed(
&self,
provider: &str,
levels: &mut Levels,
reaching: usize,
) -> Result<Level, Unresolved>
pub async fn app_children_listed( &self, provider: &str, levels: &mut Levels, reaching: usize, ) -> Result<Level, Unresolved>
Self::app_children for a listing: what each container and chain
holds is read as far as one page of the listing reaches, reaching
resources and one past them so that the page and whether more follow
are whole (Self::listed_level), not the whole of it. A tracker of
thousands of issues read whole took several pages, each waiting behind
whatever the workspace was writing, and while an import wrote between
every two of them the read never held one revision and the listing
failed.
Source§impl<P: ActionProvider + Sync + Clone + Send + 'static> Tree<P>
impl<P: ActionProvider + Sync + Clone + Send + 'static> Tree<P>
Sourcepub async fn invoke(
&self,
target: RemoteActionTarget,
argument: InvokeArgument,
invocation: InvocationId,
revision: Option<String>,
wait: Option<Duration>,
) -> Result<Called, Unresolved>
pub async fn invoke( &self, target: RemoteActionTarget, argument: InvokeArgument, invocation: InvocationId, revision: Option<String>, wait: Option<Duration>, ) -> Result<Called, Unresolved>
Call target with argument under invocation, at revision when the caller read it
at one, and follow it for wait (none: [SETTLE_WAIT]).
A revision is one the caller read a few calls ago, and a directory moves on whenever its app’s page does: the caller is after the action, not that snapshot. A call refused as named at a revision the directory left behind is made once more without one, which the provider resolves against the directory as it is now.
§Errors
The provider refused it before admitting it, or dropped it unanswered.
Sourcepub async fn settled(
&self,
invocation: &InvocationId,
wait: Duration,
) -> Option<InvocationState>
pub async fn settled( &self, invocation: &InvocationId, wait: Duration, ) -> Option<InvocationState>
The state of invocation once it settles, or as it stands when wait has passed:
looked at again each time the provider says it may have moved, else after a pause.
Sourcepub async fn started_provider(
&self,
app_id: &str,
wait: Option<Duration>,
) -> Result<String, Unresolved>
pub async fn started_provider( &self, app_id: &str, wait: Option<Duration>, ) -> Result<String, Unresolved>
The provider of a running instance of the installed app app_id, starting the app in
the workspace when none runs yet, without a window: where an invocation of the app’s
own actions goes. wait is how long its first wait lasts.
§Errors
The caller may not start it, or it did not start.
Sourcepub async fn by_item_address(
&self,
app_id: &str,
provider: &str,
address: &str,
levels: &mut Levels,
) -> Result<Option<Resolved>, Unresolved>
pub async fn by_item_address( &self, app_id: &str, provider: &str, address: &str, levels: &mut Levels, ) -> Result<Option<Resolved>, Unresolved>
The resource address names, written either as its listing publishes
it (chat.messages/messages/m1) or in the stable form a link carries
(chat.messages.messages:m1): both name one resource, so both are
answered alike.
§Errors
A level on the way could not be read.
Sourcepub async fn by_address(
&self,
app_id: &str,
provider: &str,
address: &str,
levels: &mut Levels,
) -> Result<Option<Resolved>, Unresolved>
pub async fn by_address( &self, app_id: &str, provider: &str, address: &str, levels: &mut Levels, ) -> Result<Option<Resolved>, Unresolved>
The resource the app lists under exactly address, with its actions
and what it holds: an answer’s own naming of what it made or changed.
§Errors
A level on the way could not be read.
Source§impl<P> Tree<P>
impl<P> Tree<P>
Sourcepub fn new(
provider: P,
caller: Caller,
workspace: String,
pause: Arc<dyn Pause>,
) -> Self
pub fn new( provider: P, caller: Caller, workspace: String, pause: Arc<dyn Pause>, ) -> Self
The tree of workspace as caller walks it over provider, pausing with pause.
Sourcepub fn asking(self, asker: Asker<P>) -> Self
pub fn asking(self, asker: Asker<P>) -> Self
The tree asking its catalogue pages with asker rather than the provider’s query.
Sourcepub fn listing_resolution(
&self,
path: &str,
revision: &str,
) -> Option<ListingResolution>
pub fn listing_resolution( &self, path: &str, revision: &str, ) -> Option<ListingResolution>
The resolution path was listed by at the directory revision revision, when this
tree listed one: a later page reads by it instead of resolving the path again.
Sourcepub fn remember_listing_resolution(
&self,
path: &str,
revision: &str,
resolved: &ListingResolution,
)
pub fn remember_listing_resolution( &self, path: &str, revision: &str, resolved: &ListingResolution, )
Keep the resolution path was listed by at revision, for the page that reads on
from it. The newest [LISTING_RESOLUTIONS] are kept; what was listed before those is
resolved again when it is listed again.
Source§impl<P: ActionProvider + Sync + Clone + Send + 'static> Tree<P>
impl<P: ActionProvider + Sync + Clone + Send + 'static> Tree<P>
Sourcepub async fn ask(
&self,
query: CatalogueQuery,
) -> Result<CataloguePage, Unresolved>
pub async fn ask( &self, query: CatalogueQuery, ) -> Result<CataloguePage, Unresolved>
One catalogue page asked of the provider as this tree’s caller, waited for until it
answers, for at most ANSWER_WAIT. A workspace that just started opens the documents
a listing reads before it answers, and an ask given up sooner left the caller waiting
for an answer it was already sent. A workspace a server is not serving yet refuses the
ask and takes it once it does: its session moving is the signal to ask again.
§Errors
The provider refused it, did not answer in time, or dropped it unanswered.
Sourcepub async fn providers(
&self,
) -> Result<(String, Vec<(String, Value)>), Unresolved>
pub async fn providers( &self, ) -> Result<(String, Vec<(String, Value)>), Unresolved>
Every publisher this caller may browse in its workspace, each by its provider id with
what it is: an application’s window (a numeric peer) or one of the host’s own services
(tilo.desktop), by the app id it answers for. Host services first, then windows
oldest first, so the newest window of an app is its last entry. With them, the
revision the provider answered at.
§Errors
The provider could not be asked.
Source§impl<P: ActionProvider + Sync + Clone + Send + 'static> Tree<P>
impl<P: ActionProvider + Sync + Clone + Send + 'static> Tree<P>
Sourcepub async fn level(
&self,
provider: &str,
parent: &str,
levels: &mut Levels,
) -> Result<Level, Unresolved>
pub async fn level( &self, provider: &str, parent: &str, levels: &mut Levels, ) -> Result<Level, Unresolved>
One directory level: the resources under parent and their actions,
over as many pages as a bounded read takes.
Sourcepub async fn level_near(
&self,
provider: &str,
parent: &str,
levels: &mut Levels,
) -> Result<Level, Unresolved>
pub async fn level_near( &self, provider: &str, parent: &str, levels: &mut Levels, ) -> Result<Level, Unresolved>
One directory level, read as far as one page of a listing holds:
enough to name a resource and what it holds on its first page, and
extended by whoever pages past it (Self::level_reaching,
Self::level_holding). A listing reads one page of a directory of
thousands per call, not a fixed stretch of it.
Sourcepub fn levels_kept(&self, provider: &str) -> Levels
pub fn levels_kept(&self, provider: &str) -> Levels
The directory levels this session read in provider, as the last call
left them: what a call resolving a path there starts from.
Sourcepub fn keep_levels(&self, provider: &str, levels: &Levels)
pub fn keep_levels(&self, provider: &str, levels: &Levels)
Keep what a call resolving its path in provider read, for the calls
after it: a write on another of the app’s resources is resolved from
what the workspace already answered.
Sourcepub fn forget_app(&self, app_id: &str)
pub fn forget_app(&self, app_id: &str)
Forget the app app_id the session found, after the workspace refused a
call as one the app does not offer: the app or its directory moved
since, so the next call looks both up again. What the workspace decided
about other names — a name several apps carry, or none — is dropped with
it: the catalogue moved, and the calls that follow read it once more.
Sourcepub async fn app_ref(&self, name: &str) -> Result<AppRef, Unresolved>
pub async fn app_ref(&self, name: &str) -> Result<AppRef, Unresolved>
The app name means: a running one by its id or last part, else an
installed one the workspace offers to open.
Where a name was found is kept: every call in an app names it again, and
looking it up asks the workspace which apps run and which are installed
— two catalogue reads, for each call. So a running app is answered from
here after the first call, as a name that means an installed app is, and
so is a start this session made (Self::saw_running) and a decision
about a name no grant can change. What this caller may open is not kept:
an app that is not known to run here is looked up on every call, so a
grant given or withdrawn is decided by the call it reaches. A call the
app refuses drops what was kept ([McpServer::forget_app]), so an app
that moved is looked up again.
Sourcepub fn saw_running(&self, app_id: &str, provider: &str)
pub fn saw_running(&self, app_id: &str, provider: &str)
Keep app_id as running on provider: what a start this session made, or a call an app
answered at, proves. Every name this tree knew the app by is kept so too, so the call
after a start invokes the app instead of starting it again.
Sourcepub async fn app_ref_live(&self, name: &str) -> Result<AppRef, Unresolved>
pub async fn app_ref_live(&self, name: &str) -> Result<AppRef, Unresolved>
Self::app_ref as the live directory answers it, asked of the
workspace: the app a running one is by its id or last part, else an
installed one the workspace offers to open.
Sourcepub async fn surface_of(&self, app_id: &str) -> Option<String>
pub async fn surface_of(&self, app_id: &str) -> Option<String>
The surface the app app_id publishes, as the workspace’s catalogue carries it on the
row the app’s provider publishes: for an app that is no installed application, such as
the workspace’s own actions. None when no row names one.
Sourcepub async fn installed(&self) -> Result<Vec<InstalledApp>, Unresolved>
pub async fn installed(&self) -> Result<Vec<InstalledApp>, Unresolved>
The apps installed for this workspace, with their labels and whether this caller may open them. The workspace answers them by their kind, whole, wherever they fall among its other rows (governance, shortcuts), so a workspace with many of those still lists every app.
Sourcepub async fn named(
&self,
provider: &str,
parent: &str,
name: &str,
) -> Result<Option<Level>, Unresolved>
pub async fn named( &self, provider: &str, parent: &str, name: &str, ) -> Result<Option<Level>, Unresolved>
The resources under parent that name names (by label or kind),
asked of the app whole: one note among a notebook’s thousands costs
the rows naming it, not a page of every note. None when the app
cannot say (a host from before parents were named answers about its
top level), and the level is listed instead.
Sourcepub async fn named_at_app(
&self,
provider: &str,
name: &str,
levels: &mut Levels,
) -> Result<Option<Level>, Unresolved>
pub async fn named_at_app( &self, provider: &str, name: &str, levels: &mut Levels, ) -> Result<Option<Level>, Unresolved>
What name may mean at the app’s level, asked by name: the app’s top
level and, inside each of its containers, what name names there,
less what another of them owns; None when one cannot be asked.
Sourcepub async fn step(
&self,
provider: &str,
at: &str,
parent: Option<&Node>,
segment: &str,
levels: &mut Levels,
forms: Option<&dyn TypeNames>,
) -> Result<(Node, Level), Unresolved>
pub async fn step( &self, provider: &str, at: &str, parent: Option<&Node>, segment: &str, levels: &mut Levels, forms: Option<&dyn TypeNames>, ) -> Result<(Node, Level), Unresolved>
The resource segment names under parent (the app itself for
None), and the resources it was named among. A name only one
resource there carries is asked of the app by name; anything else (a
key, the start of a name, a name several carry, one that is not
there) is decided on the whole level, as listing it shows. With them
comes the directory revision it was found at. at is the address the
level is listed at, which a name not found is answered with.
Sourcepub async fn deep(
&self,
provider: &str,
name: &str,
within: Option<&Node>,
levels: &mut Levels,
forms: Option<&dyn TypeNames>,
) -> Result<Option<Node>, Unresolved>
pub async fn deep( &self, provider: &str, name: &str, within: Option<&Node>, levels: &mut Levels, forms: Option<&dyn TypeNames>, ) -> Result<Option<Node>, Unresolved>
A resource name names somewhere below within (or anywhere in the
app), found among the nodes this call has read and then by reading
the containers it has not: a note’s body is published beside the
note rather than inside it, and its key says whose it is.
Sourcepub async fn resolve(
&self,
parsed: &Address,
forms: Option<&dyn TypeNames>,
) -> Result<(Resolved, bool), Unresolved>
pub async fn resolve( &self, parsed: &Address, forms: Option<&dyn TypeNames>, ) -> Result<(Resolved, bool), Unresolved>
Resolve a whole path. A segment written the way a program types a type (tasks.Task)
is read as that type first: it names the resource whose published kind the listing
prints that name for. Only a segment written that way is asked of the task’s programs,
so a path of titles (notes/Todo) does not start a task’s host to read a name already
said; a form no app declares falls back to the plain reading, where it may be a title.
With the resolution come the forms it was read by (None when it was read plainly), so
a caller that shows what it found names the type the same way without asking again.
Sourcepub async fn resolve_with(
&self,
parsed: &Address,
forms: Option<&dyn TypeNames>,
reaching: usize,
) -> Result<Resolved, Unresolved>
pub async fn resolve_with( &self, parsed: &Address, forms: Option<&dyn TypeNames>, reaching: usize, ) -> Result<Resolved, Unresolved>
Self::resolve reading the names a path segment may go by as forms says they are
written: a segment names a type by the name a listing prints for it (tasks.Task),
which forms reads back as its kind. reaching is how many resources of an app’s own
page to read its containers for: a listing reads the page’s end and one past it, and
a read takes every one (usize::MAX).
Sourcepub async fn resolve_published(
&self,
parsed: &Address,
app_id: String,
newest: String,
list: bool,
forms: Option<&dyn TypeNames>,
levels: &mut Levels,
reaching: usize,
) -> Result<Resolved, Unresolved>
pub async fn resolve_published( &self, parsed: &Address, app_id: String, newest: String, list: bool, forms: Option<&dyn TypeNames>, levels: &mut Levels, reaching: usize, ) -> Result<Resolved, Unresolved>
Self::resolve_in the newest instance newest of app_id, or, when
it has published nothing for the path, the app’s older instances in
turn. A path names the app, not one of its processes: an instance
lists as running a moment before it publishes its directory, and must
not hide an older one that has (an agent saw an app’s actions, and
the next call found none).
Sourcepub async fn resolve_in(
&self,
parsed: &Address,
app_id: String,
provider: String,
list: bool,
forms: Option<&dyn TypeNames>,
levels: &mut Levels,
reaching: usize,
) -> Result<Resolved, Unresolved>
pub async fn resolve_in( &self, parsed: &Address, app_id: String, provider: String, list: bool, forms: Option<&dyn TypeNames>, levels: &mut Levels, reaching: usize, ) -> Result<Resolved, Unresolved>
Resolve the segments of parsed in the running app app_id, whose
instance is provider. With list, what the target holds and the
actions on it are read too; without, a resource on the path is only
found (an action named on it is resolved by its address). forms is how
a path segment may name a type the way a program types it
(tasks.Task), as a listing names it. reaching is how far what an
app’s own page merges from its containers is read: a listing’s end and
one resource past it, or every one (Self::app_children_listed).
Source§impl<P: ActionProvider + Sync + Clone + Send + 'static> Tree<P>
impl<P: ActionProvider + Sync + Clone + Send + 'static> Tree<P>
Sourcepub async fn app_of_type(&self, name: &str) -> Option<(String, String, bool)>
pub async fn app_of_type(&self, name: &str) -> Option<(String, String, bool)>
The app a kind names (tasks.tracker is the Tasks app’s tracker), as
the app id and the provider serving it: a kind begins with the app it
belongs to. None when the name is no kind, or its app is not here or
is not the agent’s to open.
An app that is installed but not running is started without a window, as an action on it is: a cold link addresses a resource of the app the device never showed, and the app that publishes it serves its kind once it runs.
Auto Trait Implementations§
impl<P> !Freeze for Tree<P>
impl<P> !RefUnwindSafe for Tree<P>
impl<P> !UnwindSafe for Tree<P>
impl<P> Forget for Tree<P>
impl<P> Move for Tree<P>
impl<P> Send for Tree<P>where
P: Send,
Option<Box<dyn Fn(&P, &Caller, CatalogueQuery) -> Pending<Result<CataloguePage, ActionCallError>> + Send + Sync>>: Send,
impl<P> Sync for Tree<P>where
P: Sync,
Option<Box<dyn Fn(&P, &Caller, CatalogueQuery) -> Pending<Result<CataloguePage, ActionCallError>> + Send + Sync>>: Sync,
impl<P> Unpin for Tree<P>where
P: Unpin,
Option<Box<dyn Fn(&P, &Caller, CatalogueQuery) -> Pending<Result<CataloguePage, ActionCallError>> + Send + Sync>>: Unpin,
impl<P> UnsafeUnpin for Tree<P>where
P: UnsafeUnpin,
Option<Box<dyn Fn(&P, &Caller, CatalogueQuery) -> Pending<Result<CataloguePage, ActionCallError>> + Send + Sync>>: UnsafeUnpin,
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> 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