pub struct RecordEnv<R: Resource> { /* private fields */ }Expand description
The record, run and storage a view or surface works in. See the module docs.
Implementations§
Source§impl<R: Resource> RecordEnv<R>
impl<R: Resource> RecordEnv<R>
Sourcepub fn waker(&self) -> WakeHandle
pub fn waker(&self) -> WakeHandle
Wakes the app from another thread — a worker’s result, a socket’s message — so the window syncs and draws it without waiting for input.
Sourcepub fn open_here(
&self,
arguments: &[String],
) -> Result<ReplacementOutcome, String>
pub fn open_here( &self, arguments: &[String], ) -> Result<ReplacementOutcome, String>
Open, in this window and in place of the record it shows, what a
launch of the app naming arguments opens: the record
ResourceApp::launch_record
names, with its launch actions — the document a person chose with
the app’s own Open. The window’s view is rebuilt for that record on
the next frame. Refused in a past version and a capture.
The outcome answers once the host opened it, or why it could not.
Sourcepub fn record_id(&self) -> Option<&RecordId>
pub fn record_id(&self) -> Option<&RecordId>
The host-owned identity of the record this window shows. A durable activation link can name it without relying on the last-open window. Absent in a historical view that cannot launch live work.
Sourcepub fn opener(&self) -> Option<OpenHere>
pub fn opener(&self) -> Option<OpenHere>
What Self::open_here does, kept for later: the input that asks
for another record arrives after the view is built (a file chosen in
a picker, a clicked notification). None in a past version and a
capture.
Sourcepub fn window_documents(&self) -> Vec<WindowDocument<R>>
pub fn window_documents(&self) -> Vec<WindowDocument<R>>
The documents this app’s windows started in this workspace, each as
last kept, the most recently changed first, without the one this
window shows: what an app whose windows each show a document of their
own (ResourceApp::WINDOW_RESOURCE)
lists, so a document made in a window that was closed is reached
again. Open one here with Self::open_here naming
WindowDocument::uri. Reads every one of them, so ask when the
list is shown, not on every frame. Empty in a past version and where
the window keeps no records in a workspace.
Sourcepub fn people(&self) -> People
pub fn people(&self) -> People
The names of the participants, for showing the ids actions record
(People::name).
Sourcepub fn dispatcher(&self) -> Dispatcher<R>
pub fn dispatcher(&self) -> Dispatcher<R>
Where edits go. Custom widgets keep a clone.
Sourcepub fn child<C: Resource>(
&self,
id: &str,
wrap: impl Fn(C::Action) -> R::Action + 'static,
) -> Dispatcher<C>
pub fn child<C: Resource>( &self, id: &str, wrap: impl Fn(C::Action) -> R::Action + 'static, ) -> Dispatcher<C>
The dispatcher of the resource nested in this one at id, whose
edits are this resource’s action wrap(edit): a rich-text body, a
draft, a SQL buffer. See Dispatcher::child.
Sourcepub fn chain<P: Chained<Base = R>>(&self) -> Option<Chain<P>>
pub fn chain<P: Chained<Base = R>>(&self) -> Option<Chain<P>>
The chain of P the app keeps beside its record
(Chain): its parts, read as they change, and its
dispatcher. None in a view of a past version, or where P’s base
is not this record’s resource.
Sourcepub fn chain_beside<P: Chained<Base = R>>(
&self,
beside: &WorkspaceRecord<R>,
) -> Option<Chain<P>>
pub fn chain_beside<P: Chained<Base = R>>( &self, beside: &WorkspaceRecord<R>, ) -> Option<Chain<P>>
The chain of P kept beside the record beside rather than beside
this window’s own (Chained::chain_beside):
the messages of one direct conversation, kept in the record the two
people share. P’s base is the type of beside’s record.
Sourcepub fn children<C: ChildRecord<Parent = R>>(&self) -> Option<Children<C>>
pub fn children<C: ChildRecord<Parent = R>>(&self) -> Option<Children<C>>
The children of C this record lists (Children):
each a record of its own, read as they change, with the one
lifecycle every container has. None in a view of a past version,
or where C’s parent is not this record’s resource.
Sourcepub fn me(&self) -> Option<&str>
pub fn me(&self) -> Option<&str>
Who this view is for: the participant reading and editing through
it, the same id an action they invoke reads as its author
(ActionCx::author). Compare the
authors the resource records with it (“your message”, “you reacted”)
instead of keeping the reader in the resource state, which is the
same for everyone. None in a view of a past version.
Sourcepub fn is_past(&self) -> bool
pub fn is_past(&self) -> bool
Whether this view shows a past version in History mode, drawn from a frozen document. It must start no work there: a surface that fetches, watches or spawns a worker is built without it and presents what the document holds.
Sourcepub fn read_only(&self) -> bool
pub fn read_only(&self) -> bool
Whether this participant may only view, when the view is built.
Bound controls already follow permission changes on their own; to show
or disable something else while the participant may only view, bind to
ViewCx::read_only_state, which follows role changes while the app
runs.
Sourcepub fn save_status(&self) -> LocalState<RecordSaveStatus>
pub fn save_status(&self) -> LocalState<RecordSaveStatus>
Whether the record’s latest edits are durable, for automation and an accessibility status. Saving is automatic and the window already says what there is to say (a save that stalls or fails, and the document’s unsaved mark then): never show this as “Saving…” or “Saved”, nor mark the document edited from it.
Sourcepub fn saves(&self) -> Saves
pub fn saves(&self) -> Saves
The window’s report of saves the app makes outside its record (a
file it writes), presented with the record’s own on the window’s
save status. See Saves.
Sourcepub fn workspace(&self) -> Option<String>
pub fn workspace(&self) -> Option<String>
The workspace the window keeps its records in: what an app keys what it keeps on
this device for the workspace by (a cache, an index). None in a past version and where the
window keeps no records in a workspace.
Sourcepub fn workspace_handle(&self) -> Option<WorkspaceHandle>
pub fn workspace_handle(&self) -> Option<WorkspaceHandle>
The records every app of the window’s workspace opens, held for what
settles after the view that asked for one (an action’s reply, a
message from another device): a conversation’s record is opened and
followed through it, in a view that is built once. None in a past
version and where the window keeps no workspace records.
Sourcepub fn mode(&self) -> RunMode
pub fn mode(&self) -> RunMode
What the view is built for: a window someone uses, a past version in History, or a screenshot. Start work that reaches outside the process (an engine, a socket, a probe) only when it is live.
Sourcepub fn fixture<V: 'static>(&self) -> Option<Rc<V>>
pub fn fixture<V: 'static>(&self) -> Option<Rc<V>>
The capture’s stand-in for a live source of type V
(Fixture::provide); None outside a
capture, or when the scenario provides none.
Sourcepub fn content(&self) -> Option<ContentStore>
pub fn content(&self) -> Option<ContentStore>
The content store the host lent the app: opaque blobs by hash that outlive it. A capture’s holds the blobs its scenario put there.
Sourcepub fn launch(&self) -> LaunchInput<'_>
pub fn launch(&self) -> LaunchInput<'_>
What the launch that opened this window named — the file a person
opened the app with, its command line — for a view that shows what
the launch’s actions (ResourceApp::launch)
made: the note a launch imported, opened. Empty for a plain start and
for a past version.
Sourcepub fn launch_arguments(&self) -> &[String]
pub fn launch_arguments(&self) -> &[String]
What the window’s launch named (paths, URLs), for a view that acts on them beyond the actions the launch took: the file a save writes back to. Empty for a plain start, a past version and a capture.
Sourcepub fn file_history(&self) -> Option<FileHistorySource>
pub fn file_history(&self) -> Option<FileHistorySource>
The file whose history History shows beside the resource’s, for an
app that declares ResourceApp::FILE_HISTORY:
set its target to the file the window shows (the selected one) and
open it from the window’s own History command. None for any other
app, and in a past version.
Sourcepub fn launch_option(&self, name: &str) -> Option<&str>
pub fn launch_option(&self, name: &str) -> Option<&str>
The value of the app’s own option name (--purpose) the window’s
launch named; see ResourceApp::OPTIONS.
None for a past version.
Sourcepub fn launch_flag(&self, name: &str) -> bool
pub fn launch_flag(&self, name: &str) -> bool
Whether the window’s launch named the app’s switch name; see
ResourceApp::FLAGS.
Sourcepub fn take_lent<S: 'static>(&self) -> Option<S>
pub fn take_lent<S: 'static>(&self) -> Option<S>
The service of type T the host that mounts the app in its own
process lent it (HostContext::lend),
taken once: the shell’s connection to the session’s process
supervisor for a terminal it hosts. None in the app’s own process,
and for a past version or a capture, which start nothing.
Sourcepub fn is_private(&self) -> bool
pub fn is_private(&self) -> bool
Whether the window is private (ResourceApp::PRIVATE_WINDOWS):
its record, settings and files are thrown away with the process. A
view keeps what it would otherwise remember on the device (visits,
a session to restore) to itself.
Sourcepub fn settings<S>(&self) -> Setting<S>
pub fn settings<S>(&self) -> Setting<S>
The app’s typed settings of type S, kept current while this scope
lives. S declares whether they follow the person or stay on the
device (Scope).
Sourcepub fn device(&self) -> Option<&str>
pub fn device(&self) -> Option<&str>
The device this window runs on: stable across launches, distinct on
each of the person’s devices. None in a view of a past version. An
action that records where something happened (a speed test run on
this device) takes it as an argument, so every replica applies the
same value.
Sourcepub fn query<T>(
&self,
target: RemoteActionTarget,
argument: InvokeArgument,
) -> Query<T>
pub fn query<T>( &self, target: RemoteActionTarget, argument: InvokeArgument, ) -> Query<T>
Read the result of the view action at target with argument,
through the session’s action door as the person using the app, and
keep it current (Query): a live action’s answer
follows its provider’s changes, one that answers once is read once.
It is followed while this scope lives.
Sourcepub fn invoke(&self, target: RemoteActionTarget, argument: InvokeArgument)
pub fn invoke(&self, target: RemoteActionTarget, argument: InvokeArgument)
Invoke the action at target of another provider with argument,
through the session’s action door as the person using the app: a
write a Self::query then reads back. Why it did not go ahead is
told as any refused call of the window is. A past version or a
capture invokes nothing.
Sourcepub fn person<P: Resource>(&self) -> Option<PersonRecord<P>>
pub fn person<P: Resource>(&self) -> Option<PersonRecord<P>>
The app’s record of P (PersonRecord):
one per kind, kept with the app’s other records in the workspace it
is open in and synced with it. None where the host keeps no such
records (a view of a past version, a private window) or the record
cannot be opened.
The record P that owner keeps in the window’s workspace and every app
of the workspace opens (collab_types::WORKSPACE_RECORDS): the
workspace’s emoji, which are Chat’s. Changes to it are decided by the
workspace’s grants on owner’s resource. None where the host keeps no
such records (a view of a past version) or it cannot be opened.
The record id of P that owner keeps in the window’s workspace,
named otherwise than Self::shared_workspace’s: a conversation’s,
which the two people it is between name. Held and decided like any
record of the owner’s: the workspace’s grants on owner decide every
change. None where the host keeps no records in a workspace (a view
of a past version), for an id that names no record, or where it
cannot be opened.
The person’s record P that one app keeps for all of theirs — their
accounts, which Settings keeps: the same record on every device, held
here too and converging with the keeper’s. Changed only by its owner
and editors (SharedRecord,
PersonRecord::editable); its owner
opens it here too.
Sourcepub fn storage(&self) -> &AppStorage
pub fn storage(&self) -> &AppStorage
The app’s files, secrets and settings documents, as its host gave
them. A secret of one document item is
cx.storage().secrets().item(purpose, id).
Sourcepub fn outbox<E, O>(
&self,
outbox: Path<R, Outbox<E, O>>,
owns: impl Fn(&R::State, &E) -> bool + 'static,
run: impl FnMut(&Id, E, &mut EffectCx<R>) -> EffectAnswer + 'static,
) -> Projection
pub fn outbox<E, O>( &self, outbox: Path<R, Outbox<E, O>>, owns: impl Fn(&R::State, &E) -> bool + 'static, run: impl FnMut(&Id, E, &mut EffectCx<R>) -> EffectAnswer + 'static, ) -> Projection
Carry out the entries of the Outbox at
outbox that this device owns, and record how each settled.
Every replica holds the entries; owns says which are this device’s
to carry out (the device whose disk a file operation names, the one
holding the mail account). For each such pending entry the framework
runs run in the live app — never in History or a capture — at once
or as a job through its EffectCx, and records the answer with
the outbox’s settle edit: content from outside, nobody’s undo step.
The answer settles the entry: Effected::settled
with how it went, Effected::value with
the result O, or Effected::done for
O’s default. An Err leaves the entry pending, to run again after
the next change or when the returned Projection is told the
outside changed (the server came back); a failure for good is a
Settled::Failed.
Sourcepub fn outbox_awaited<E, O>(
&self,
outbox: Path<R, Outbox<E, O>>,
owns: impl Fn(&R::State, &E) -> bool + 'static,
run: impl FnMut(&Id, E, &mut EffectCx<R>) -> EffectAnswer + 'static,
) -> Projection
pub fn outbox_awaited<E, O>( &self, outbox: Path<R, Outbox<E, O>>, owns: impl Fn(&R::State, &E) -> bool + 'static, run: impl FnMut(&Id, E, &mut EffectCx<R>) -> EffectAnswer + 'static, ) -> Projection
Self::outbox, where an entry is the outside half of the action
that queued it: one an admitted invocation on this device queues runs
at once under that invocation — cx.invocation() names it, and its
custody authorises what the handler does for it (a native host that
acts only on behalf of an invocation) — and the invocation completes
only once its entries settled, failing with a failed one. Entries
queued elsewhere, replayed or still pending after a restart run as
Self::outbox runs them, with no invocation.
Trait Implementations§
Auto Trait Implementations§
impl<R> Freeze for RecordEnv<R>
impl<R> !RefUnwindSafe for RecordEnv<R>
impl<R> !Send for RecordEnv<R>
impl<R> !Sync for RecordEnv<R>
impl<R> Unpin for RecordEnv<R>
impl<R> UnsafeUnpin for RecordEnv<R>
impl<R> !UnwindSafe for RecordEnv<R>
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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