Skip to main content

Recomposer

Struct Recomposer 

Source
pub struct Recomposer { /* private fields */ }
Expand description

The slot table runtime for one root: what composes the tree and runs its handlers.

Every method enters the composition for its own length, so it may be called from any Host call on the UI thread. The tree’s records go into [Recomposer::writer]’s batch, between whatever the Host writes before and after them.

Implementations§

Source§

impl Recomposer

Source

pub fn new(content: impl Fn() + 'static) -> Self

A runtime for content, composed by Recomposer::rebuild.

Source

pub fn arena(&self) -> (*const u8, usize)

The batch arena.

Source

pub fn size_token(&self, node_id: u32) -> Option<u32>

The application’s name for a node it asked to have measured, if it asked.

Source

pub fn rebuild(&mut self)

Composes the whole tree. Called once, on a fresh runtime.

Source

pub fn render(&mut self, frame_time_nanos: Option<u64>)

Writes whatever changed since the last call: a frame’s time to whatever waits for one, the futures that woke, and the scopes the states written since invalidated.

Source

pub fn handle_event( &mut self, event: &HostEvent<'_>, ) -> Result<i64, ProtocolError>

Runs the handler an event names, and nothing else; the caller renders afterwards.

Returns what the boundary hands back as the call’s result, which is how a key handler says it consumed the key. An event naming a handler or node this composition does not have is an error, and so is a payload no handler can take.

Source

pub fn run_in_context(&mut self, action: &mut dyn FnMut())

Runs code the application handed to the Host, a message’s action for one, with this composition current, so the states it writes are picked up by the next render.

Trait Implementations§

Source§

impl Runtime for Recomposer

Source§

fn batch(&self) -> &Batch

The batch this runtime writes the tree’s records into. The Host writes its own records into the same one, before and after the runtime’s.
Source§

fn batch_mut(&mut self) -> &mut Batch

Source§

fn rebuild(&mut self)

Writes the whole tree. Called once on a fresh runtime, which is also what a resync gets: the Host makes a new runtime and rebuilds it.
Source§

fn render(&mut self, frame_time_nanos: Option<u64>)

Writes whatever changed since the last call: state a worker wrote, a scope that a size class or a design system woke, the consequences of an event. Read more
Source§

fn handle_event(&mut self, event: &HostEvent<'_>) -> Result<i64, ProtocolError>

Runs the handler an event names, and nothing else: the Host renders afterwards. Read more
Source§

fn size_token(&self, node_id: u32) -> Option<u32>

The application’s name for a node it asked to have measured, if it asked.
Source§

fn run_in_context(&mut self, action: &mut dyn FnMut())

Runs code the application handed to the Host, a message’s action for one, inside whatever context this runtime’s state writes need.
Source§

fn poll_work(&mut self, context: &mut Context<'_>) -> Poll<()>

Whether the runtime has work waiting that a frame should run. A runtime that is woken by something outside a boundary call (a timer, a task it spawned) wakes the context’s waker, and the Host turns that into a frame request.

Auto Trait Implementations§

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 = !

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.