Struct HostContext
pub struct HostContext { /* private fields */ }Expand description
Explicit identity, authority and storage. Apps receive no ambient profile resolver.
Implementations§
§impl HostContext
impl HostContext
pub fn reopener(&self) -> Reopener
pub fn reopener(&self) -> Reopener
What the component needs to open another record of its app in its
window later (Reopener).
pub fn prepare(
definition: &ApplicationDefinition,
inputs: HostContextInputs,
target: &LaunchTarget,
) -> Result<HostContext, LaunchError>
pub fn prepare( definition: &ApplicationDefinition, inputs: HostContextInputs, target: &LaunchTarget, ) -> Result<HostContext, LaunchError>
Reserve New or open Existing before the factory, using only supplied identities.
§Errors
Rejects denied authority, invalid/foreign namespaces and unavailable records.
pub fn prepare_new_record(
definition: &ApplicationDefinition,
inputs: HostContextInputs,
record_id: RecordId,
) -> Result<HostContext, LaunchError>
pub fn prepare_new_record( definition: &ApplicationDefinition, inputs: HostContextInputs, record_id: RecordId, ) -> Result<HostContext, LaunchError>
Reserve a host-named new record through the same checked construction path. Useful for a workspace’s default document, whose identity must survive a restart even before the first local View has been saved. Existing records are never adopted or reinitialized by this operation.
§Errors
Rejects foreign namespaces, denied authority and occupied identities.
Commit this instance’s edits to its record under an actor of its
author’s own (crate::record::author_writer) rather than the
record’s writer, which every instance sharing the record’s store
writes as. For a host that mounts several authors on one store (a
page’s mounts of one profile and device), so history can tell whose
edit each change is. The record’s writer, which the store persists,
is unchanged, as is everything written outside the instance.
pub fn provide_content(&mut self, store: ContentStore)
pub fn provide_content(&mut self, store: ContentStore)
Lend the component the host’s content store for this storage scope: opaque bytes addressed by hash that outlive the component and that other components of the same scope read too.
pub fn content(&self) -> Option<&ContentStore>
pub fn content(&self) -> Option<&ContentStore>
The content store the host lent, if any.
pub fn provide_open_file(&mut self, file: OpenFile)
pub fn provide_open_file(&mut self, file: OpenFile)
Hand the component a file to open. ApplicationDefinition::instantiate
refuses the launch unless the definition opens its media type.
pub fn take_open_file(&mut self) -> Option<OpenFile>
pub fn take_open_file(&mut self) -> Option<OpenFile>
The file the host handed over to open, once.
pub fn provide_capture(&mut self, capture: Capture)
pub fn provide_capture(&mut self, capture: Capture)
Prepare the instance for a screenshot of capture instead of a
window someone uses.
pub fn capture(&self) -> Option<&Capture>
pub fn capture(&self) -> Option<&Capture>
The screenshot this instance is prepared for, if it is one.
pub fn provide_launch_arguments(&mut self, arguments: Vec<String>)
pub fn provide_launch_arguments(&mut self, arguments: Vec<String>)
Hand the component what its launch named besides a file: the arguments of a command line or an “open with” (paths, URLs), in order. The host has already checked how many the component accepts.
pub fn take_launch_arguments(&mut self) -> Vec<String>
pub fn take_launch_arguments(&mut self) -> Vec<String>
The launch arguments the host handed over, once.
pub fn provide_handoff(&mut self, handoff: PlaybackHandoff)
pub fn provide_handoff(&mut self, handoff: PlaybackHandoff)
Hand the component the playback another device or app handed over with the media its launch names.
pub fn take_handoff(&mut self) -> Option<PlaybackHandoff>
pub fn take_handoff(&mut self) -> Option<PlaybackHandoff>
The playback handoff the host handed over, once.
pub fn lend<T>(&mut self, service: T)where
T: Any,
pub fn lend<T>(&mut self, service: T)where
T: Any,
Lend the component a service of the host that mounts it in its own process: a connection to the session’s process supervisor for a terminal the shell hosts. The component takes it by type; a host that lends nothing leaves the app on its own services.
pub fn provide_launch_options(&mut self, options: Vec<LaunchOption>)
pub fn provide_launch_options(&mut self, options: Vec<LaunchOption>)
Hand the component the options of its own that its launch named
(--purpose number). The host has already checked that the
component takes each of them.
pub fn take_launch_options(&mut self) -> Vec<LaunchOption>
pub fn take_launch_options(&mut self) -> Vec<LaunchOption>
The launch options the host handed over, once.
pub fn provide_private(&mut self)
pub fn provide_private(&mut self)
Prepare the instance as a private window: its profile is thrown away with the process, and nothing it shows reaches the person’s other windows, devices or collaborators.
pub fn is_private(&self) -> bool
pub fn is_private(&self) -> bool
Whether the instance is a private window.
pub fn control_domain(&self) -> ControlDomain
pub fn control_domain(&self) -> ControlDomain
Explicit owner-bound producer capability, available before factory work.
pub fn record(&self) -> &RecordCheckout
pub fn window_records(&self) -> Vec<(RecordId, AutoCommit)>
pub fn window_records(&self) -> Vec<(RecordId, AutoCommit)>
The per-window records this app’s windows kept in this room before it
kept one record per room,
read-only and sorted by id (RecordStore::window_records). Only a
context of the room’s own record answers: what the app adopts into
it when it creates it. Any other context has none.
pub fn permissions(&self) -> PermissionContext
pub fn permissions(&self) -> PermissionContext
A snapshot of the participant’s permissions at this moment.
pub fn live_permissions(&self) -> LivePermissions
pub fn live_permissions(&self) -> LivePermissions
The participant’s permissions as they change while the component runs (a role change, a revoked share). Components that present themselves read-only hold this instead of deciding once at launch.
pub fn action_context(&self) -> &ActionContext
pub fn wake_handle(&self) -> WakeHandle
pub fn services(&self) -> &HostServices
pub fn services(&self) -> &HostServices
The host services this component was prepared under — the ones
crate::host::current resolved when the host prepared it.
pub fn secrets(&self) -> SecretStore
pub fn secrets(&self) -> SecretStore
This app’s secrets, in the store its host provides: the system’s (the Secret Service, the Keychain, the browser’s wrapped store) or a host’s own. Other apps’ secrets are out of reach.
pub fn files(&self) -> AppFiles
pub fn files(&self) -> AppFiles
This app’s private file areas (data, config, cache, state): the
per-user directories natively, the origin-private file system in a
page. See crate::storage for what belongs where.
pub fn settings<T>(&self) -> Settings<T>where
T: SettingsSchema,
pub fn settings<T>(&self) -> Settings<T>where
T: SettingsSchema,
This app’s typed settings of type T, in the settings document the
host gave it (Self::provide_settings); T declares how far they
travel.
pub fn storage(&self) -> AppStorage
pub fn storage(&self) -> AppStorage
This app’s files, secrets and settings in one handle, as framework views and surfaces receive them.
pub fn provide_settings(&mut self, document: SettingsDocument)
pub fn provide_settings(&mut self, document: SettingsDocument)
Give the component this settings document instead of the person’s session document: a test or capture profile’s own.
pub fn provide_files(&mut self, files: AppFiles)
pub fn provide_files(&mut self, files: AppFiles)
Give the component these file areas instead of the person’s: a test or capture profile’s own, so nothing it writes lands in theirs.
pub fn provide_person_records(&mut self, records: PersonRecords)
pub fn provide_person_records(&mut self, records: PersonRecords)
Give the component the person’s own records of this app
(crate::record::person), kept beside the record it shows.
pub fn device_id(&self) -> &str
pub fn device_id(&self) -> &str
This device, as the host names it: stable across launches of the app on it, distinct on each of the person’s devices.
pub fn person_records(&self) -> Option<&PersonRecords>
pub fn person_records(&self) -> Option<&PersonRecords>
The person’s own records of this app, when the host keeps them.
pub fn migrate_record(
&self,
migrate: impl FnOnce(&mut AutoCommit) -> Result<bool, String>,
) -> Result<bool, String>
pub fn migrate_record( &self, migrate: impl FnOnce(&mut AutoCommit) -> Result<bool, String>, ) -> Result<bool, String>
Bring the record up to the storage version its app reads, before it
is read: migrate makes at most one deterministic housekeeping change
(two devices migrating the same document make the same one) and
answers whether it changed anything.
§Errors
The record is not open here, or the migration failed.
pub fn read_record<R>(
&self,
read: impl FnOnce(&AutoCommit) -> R,
) -> Result<R, RecordOpenError>
pub fn read_record<R>( &self, read: impl FnOnce(&AutoCommit) -> R, ) -> Result<R, RecordOpenError>
Read/project an existing or initialized document. No untracked sync mutation.
§Errors
A reserved or missing record cannot be read.
pub fn merge_peer_document(&self, document: Vec<u8>) -> Result<bool, String>
pub fn merge_peer_document(&self, document: Vec<u8>) -> Result<bool, String>
Merge another participant’s copy of the record, as their changes arriving over sync are merged: validated first, attributed to them in history, and never on this participant’s undo stack. Returns whether anything changed.
§Errors
The document is not a valid copy of this record, or it is not open.
pub fn initialize_new_record(
&mut self,
initialize: impl FnOnce(&mut AutoCommit) -> Result<(), String>,
) -> Result<(), RecordOpenError>
pub fn initialize_new_record( &mut self, initialize: impl FnOnce(&mut AutoCommit) -> Result<(), String>, ) -> Result<(), RecordOpenError>
The unique owner transition from Reserved to Ready. Existing is never initialized.
§Errors
Refuses repeated initialization and preserves the reservation on schema/storage failure.
pub fn initialize_new_record_seeded(
&mut self,
initialize: impl FnOnce(&mut AutoCommit) -> Result<(), String>,
seed: impl FnOnce(&mut AutoCommit) -> Result<(), String>,
) -> Result<(), RecordOpenError>
pub fn initialize_new_record_seeded( &mut self, initialize: impl FnOnce(&mut AutoCommit) -> Result<(), String>, seed: impl FnOnce(&mut AutoCommit) -> Result<(), String>, ) -> Result<(), RecordOpenError>
Self::initialize_new_record, then seed the record as this
author on this device. The genesis initialize writes is the same on
every device; the seed is what depends on who creates the record or
where, and is nobody’s undo step. See
RecordReservation::initialize_seeded.
§Errors
As Self::initialize_new_record; a failing seed fails it too.
pub fn creation_workspace(&self) -> Option<&CreationWorkspace>
pub fn creation_workspace(&self) -> Option<&CreationWorkspace>
The host-derived original creation scope, absent on every ordinary restore.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for HostContext
impl !RefUnwindSafe for HostContext
impl !Send for HostContext
impl !Sync for HostContext
impl Unpin for HostContext
impl UnsafeUnpin for HostContext
impl !UnwindSafe for HostContext
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
§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> 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