Skip to main content

LocalEngine

Struct LocalEngine 

Source
pub struct LocalEngine<M: TextEngine + 'static> { /* private fields */ }
Expand description

An engine driven by its host’s event loop instead of a thread of its own: the browser’s main thread in WebAssembly, where there are no threads to block. Input sent through its EngineControl is handled at the next LocalEngine::pump.

Implementations§

Source§

impl<M: TextEngine + 'static> LocalEngine<M>

Source

pub fn start<S: MountSink>( config: EngineConfig, text_engine: M, sink: S, ) -> Option<Self>

Starts the app (its first frame goes to sink before this returns); None if it could not start (reported to sink).

Source

pub fn start_with<S: MountSink>( config: EngineConfig, text_engine: M, sink: S, setup: impl FnOnce(&EngineControl), ) -> Option<Self>

LocalEngine::start, with setup sending input before the engine starts, as Engine::start_with’s does: the link that launched the app is there before its code runs.

Source

pub fn control(&self) -> EngineControl

A handle for sending input.

Source

pub fn set_wake(&mut self, wake: Arc<dyn Fn() + Send + Sync>)

Calls wake when there is work outside a pump: a component task is woken or Rust posts a JS call while no pump runs (a callback of the host’s completing what a task waits for, such as a WebSocket message through wasm-bindgen), once per wake-up, or a pump ends with work its bound left. The host then calls pump soon, instead of only at the deadline it returned or at the next input. What a pump wakes itself (a task waking another, a reply it hands over) it runs without calling wake.

Source

pub fn extend_ui_sets(&mut self, ui_sets: &[Registry])

Serves ui_sets (a superset of the config’s, after a UI set or part was registered while the app runs: the web runtime’s late gates) to what is mounted from now on.

Source

pub fn pump(&mut self) -> Option<Instant>

Handles the input sent since the last call, runs what is due (timers, tasks) and commits. Returns when to call again at the latest (sooner if input arrives); None: only for input.

Trait Implementations§

Source§

impl<M: TextEngine + 'static> Drop for LocalEngine<M>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<M> !Freeze for LocalEngine<M>

§

impl<M> !RefUnwindSafe for LocalEngine<M>

§

impl<M> !Send for LocalEngine<M>

§

impl<M> !Sync for LocalEngine<M>

§

impl<M> !UnwindSafe for LocalEngine<M>

§

impl<M> Forget for LocalEngine<M>

§

impl<M> Move for LocalEngine<M>

§

impl<M> Unpin for LocalEngine<M>
where ManuallyDrop<Driver<M>>: Unpin,

§

impl<M> UnsafeUnpin for LocalEngine<M>
where ManuallyDrop<Driver<M>>: UnsafeUnpin,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ParallelSend for T

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more