Skip to main content

PhoneHost

Struct PhoneHost 

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

Source

pub fn new(transport: T) -> Self

Starts a phone host over transport, adopting the phone surface preset.

Source

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.

Source

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.

Source

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.

Source

pub fn caps(&self) -> &SurfaceCaps

The phone’s advertised surface capabilities (the phone preset).

Source

pub fn queued(&self) -> usize

The number of Intents waiting in the offline queue.

Source

pub fn last_scene(&self, pane: &Symbol) -> Option<&Expr>

The most recently cached Scene for pane, if one was rendered.

Source

pub fn transport_mut(&mut self) -> &mut T

Mutable access to the underlying transport, e.g. to drive reconnection.

Auto Trait Implementations§

§

impl<T> Freeze for PhoneHost<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for PhoneHost<T>
where T: RefUnwindSafe,

§

impl<T> Send for PhoneHost<T>
where T: Send,

§

impl<T> Sync for PhoneHost<T>
where T: Sync,

§

impl<T> Unpin for PhoneHost<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for PhoneHost<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for PhoneHost<T>
where T: UnwindSafe,

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.