Struct Builder

Source
pub struct Builder<G> { /* private fields */ }

Implementations§

Source§

impl<G: GlobalEventHandler> Builder<G>

Source

pub fn disable_hot_reload(&mut self)

Disable hot reloading

Source

pub fn register_widget<T: Widget + Default + 'static>( &mut self, ident: &'static str, )

Register a new widget

Source

pub fn fps(&mut self, fps: u32)

Set the expected frame rate

Source

pub fn emitter(&self) -> Emitter

Returns an Emitter to send messages to components

Source

pub fn template( &mut self, ident: impl Into<String>, template: impl ToSourceKind, ) -> Result<()>

Registers a component as a template-only component.

This component has no state or reacts to any events

Source

pub fn component<C: Component>( &mut self, ident: impl Into<String>, template: impl ToSourceKind, component: C, state: C::State, ) -> Result<ComponentId<C::Message>>

Registers a Component with the runtime. This returns a unique ComponentId that is used to send messages to the component.

A component can only be used once in a template. If you want multiple instances, register the component as a prototype instead, see [RuntimeBuilder::prototype].

Source

pub fn default<C>( &mut self, ident: impl Into<String>, template: impl ToSourceKind, ) -> Result<ComponentId<C::Message>>
where C: Component + Default, C::State: Default,

Registers a Component with the runtime as long as the component and the associated state implements the Default trait. This returns a unique ComponentId that is used to send messages to the component.

Source

pub fn prototype<FC, FS, C>( &mut self, ident: impl Into<String>, template: impl ToSourceKind, proto: FC, state: FS, ) -> Result<()>
where FC: 'static + Fn() -> C, FS: 'static + FnMut() -> C::State, C: Component + 'static,

Registers a Component as a prototype with the Runtime, which allows for multiple instances of the component to exist the templates.

Source

pub fn with_global_event_handler<Eh>( self, global_event_handler: Eh, ) -> Builder<Eh>
where Eh: Fn(Event, &mut TabIndex<'_, '_>, &mut DeferredComponents) -> Option<Event>,

Assign a new event handler (make sure not to forget to add some mechanism to stop the runtime)

Source

pub fn finish<F, B>(self, backend: &mut B, f: F) -> Result<()>
where F: FnMut(&mut Runtime<G>, &mut B) -> Result<()>, B: Backend,

Source

pub fn register_function( &mut self, ident: impl Into<String>, f: impl Into<Function>, ) -> Result<()>

Auto Trait Implementations§

§

impl<G> Freeze for Builder<G>
where G: Freeze,

§

impl<G> !RefUnwindSafe for Builder<G>

§

impl<G> !Send for Builder<G>

§

impl<G> !Sync for Builder<G>

§

impl<G> Unpin for Builder<G>
where G: Unpin,

§

impl<G> !UnwindSafe for Builder<G>

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.