Skip to main content

Batch

Struct Batch 

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

One batch, written by the runtime and by the Host into the same arena.

The Host opens it with Batch::begin, writes the records that are its own (the theme, the window, assets, messages, notifications, streamed tails) and has the runtime write the tree’s records between them, then closes it with Batch::finish. The bytes that come back are what the boundary hands the Renderer.

A runtime has no fallible way to report a bad record from the middle of a diff, so Batch::fail keeps the error and finish returns it in place of the batch.

Implementations§

Source§

impl Batch

Source

pub fn new() -> Self

Sized so that an ordinary screen’s batches never grow it: once warm, writing a frame allocates nothing.

Source

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

The batch arena, so a Renderer that reads Host memory through a mapped view can be handed one.

Source

pub fn begin(&mut self)

Starts a new batch, discarding the previous one and any error it carried.

Source

pub fn finish(&mut self) -> Result<&[u8], ProtocolError>

Closes the batch and returns its bytes, or the first error written into it.

Source

pub fn write(&mut self, mutation: Mutation<'_>)

Writes one record. After an error nothing more is written: the batch is already going to be refused.

Source

pub fn fail(&mut self, error: ProtocolError)

Records an error found while building the batch. finish returns it.

Source

pub fn set_theme(&mut self, theme: Theme)

The root theme record. Written once per rebuild, never per frame.

Source

pub fn set_window(&mut self, window: Window)

The root window record. Written once per rebuild, never per frame.

Source

pub fn set_text_node( &mut self, node_id: u32, text: &str, selection: Option<Selection>, )

Source

pub fn register_asset(&mut self, asset_id: u32, kind: AssetKind, bytes: &[u8])

Copies one asset into the batch. The bytes ride behind the records, and the Renderer takes its own copy inside the call that carries them.

Source

pub fn release_asset(&mut self, asset_id: u32)

Source

pub fn show_message( &mut self, handler_id: u64, text: &str, action: &str, duration: MessageDuration, )

Writes one transient message into the batch.

It names no node, because a message is not in the tree: it is a sentence with a lifetime, and that lifetime belongs to the Renderer.

Source

pub fn append_text_node(&mut self, node_id: u32, text: &str)

Appends the streamed tail to a Text node without resending its whole value.

Trait Implementations§

Source§

impl Default for Batch

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Batch

§

impl RefUnwindSafe for Batch

§

impl Send for Batch

§

impl Sync for Batch

§

impl Unpin for Batch

§

impl UnsafeUnpin for Batch

§

impl UnwindSafe for Batch

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.