pub struct PhoneHost<T: Transport> { /* private fields */ }Expand description
A phone host facade: a single-pane Session that caches the last rendered
frame and queues Intents while offline, flushing them on resume.
The phone reuses the session bus wholesale. Its only added policy is offline
safety: PhoneHost::submit commits immediately when connected, but parks
Intents in an in-memory queue when the transport is down, and
PhoneHost::resume replays that queue in order once the caller has
restored the connection.
Implementations§
Source§impl<T: Transport> PhoneHost<T>
impl<T: Transport> PhoneHost<T>
Sourcepub fn new(transport: T) -> Self
pub fn new(transport: T) -> Self
Starts a phone host over transport, adopting the phone surface preset.
Sourcepub fn open(
&mut self,
cx: &mut Cx,
registry: &LensRegistry,
resource: Symbol,
) -> Result<Expr>
pub fn open( &mut self, cx: &mut Cx, registry: &LensRegistry, resource: Symbol, ) -> Result<Expr>
Opens resource into the phone’s single pane with the universal lenses,
caches the initial Scene, and returns it.
Sourcepub fn submit(
&mut self,
cx: &mut Cx,
registry: &LensRegistry,
intent: Expr,
) -> Result<Vec<SceneUpdate>>
pub fn submit( &mut self, cx: &mut Cx, registry: &LensRegistry, intent: Expr, ) -> Result<Vec<SceneUpdate>>
Submits an Intent against the open pane.
When the transport is SessionStatus::Connected, this commits the
Intent and pumps, caching and returning the resulting frames. Otherwise
the Intent is queued offline and an empty update list is returned – no
error – so a flaky link never drops or fails an edit.
Sourcepub fn resume(
&mut self,
cx: &mut Cx,
registry: &LensRegistry,
) -> Result<Vec<SceneUpdate>>
pub fn resume( &mut self, cx: &mut Cx, registry: &LensRegistry, ) -> Result<Vec<SceneUpdate>>
Drains the offline queue in order, replaying each Intent through the session, then pumps once and returns the resulting frames.
The queue is drained incrementally: the front Intent is removed only once
it commits. If a queued Intent fails (for example one that never
validated against the now-current value), the drain stops with that
Intent still at the front of the queue and the unprocessed tail intact –
no edit is lost, and a later resume retries from there.
Frames for the edits that did commit are pumped, cached, and returned; if
nothing committed before the failure the error is propagated.
Reconnecting the underlying transport is the caller’s concern; reach it
via PhoneHost::transport_mut before calling this.
Sourcepub fn caps(&self) -> &SurfaceCaps
pub fn caps(&self) -> &SurfaceCaps
The phone’s advertised surface capabilities (the phone preset).
Sourcepub fn last_scene(&self, pane: &Symbol) -> Option<&Expr>
pub fn last_scene(&self, pane: &Symbol) -> Option<&Expr>
The most recently cached Scene for pane, if one was rendered.
Sourcepub fn transport_mut(&mut self) -> &mut T
pub fn transport_mut(&mut self) -> &mut T
Mutable access to the underlying transport, e.g. to drive reconnection.