Skip to main content

HostedRuntime

Struct HostedRuntime 

Source
pub struct HostedRuntime<S, A, E, Id, Ctx, St = Store<S, A, E>>
where A: ActionTrait, Id: ComponentId + 'static, Ctx: BindingContext + 'static, S: EventRoutingState<Id, Ctx>, St: RuntimeStore<S, A, E>,
{ /* private fields */ }
Expand description

Runtime wrapper that keeps ComponentHost area synchronization out of app loops.

Implementations§

Source§

impl<S, A, E, Id, Ctx, St> HostedRuntime<S, A, E, Id, Ctx, St>
where S: 'static + EventRoutingState<Id, Ctx>, A: ActionTrait, Id: ComponentId + 'static, Ctx: BindingContext + 'static, St: RuntimeStore<S, A, E>,

Source

pub fn host(&self) -> &ComponentHost<S, A, Id, Ctx>

Access the hosted component host.

Source

pub fn host_mut(&mut self) -> &mut ComponentHost<S, A, Id, Ctx>

Access the hosted component host mutably.

Source

pub fn runtime(&self) -> &ComponentHostRuntime<S, A, E, Id, Ctx, St>

Access the wrapped runtime.

Source

pub fn runtime_mut(&mut self) -> &mut ComponentHostRuntime<S, A, E, Id, Ctx, St>

Access the wrapped runtime mutably.

Source

pub fn into_parts(self) -> HostedRuntimeParts<S, A, E, Id, Ctx, St>

Split the wrapper back into its runtime and host.

Source

pub fn bus(&self) -> &EventBus<S, A, Id, Ctx>

Access the event bus.

Source

pub fn bus_mut(&mut self) -> &mut EventBus<S, A, Id, Ctx>

Access the event bus mutably.

Source

pub fn keybindings(&self) -> &Keybindings<Ctx>

Access keybindings.

Source

pub fn keybindings_mut(&mut self) -> &mut Keybindings<Ctx>

Access keybindings mutably.

Source

pub fn subscribe_actions(&self) -> Receiver<String>

Subscribe to action name broadcasts.

Source

pub fn enqueue(&self, action: A)

Send an action into the runtime queue.

Source

pub fn action_tx(&self) -> UnboundedSender<A>

Clone the action sender.

Source

pub fn state(&self) -> &S

Access the current state.

Source§

impl<S, A, Id, Ctx, St> HostedRuntime<S, A, NoEffect, Id, Ctx, St>
where S: 'static + EventRoutingState<Id, Ctx>, A: ActionTrait, Id: ComponentId + 'static, Ctx: BindingContext + 'static, St: RuntimeStore<S, A, NoEffect>,

Source

pub async fn run<B, FRender, FQuit>( &mut self, terminal: &mut Terminal<B>, render: FRender, should_quit: FQuit, ) -> Result<()>
where B: Backend, FRender: FnMut(&mut Frame<'_>, Rect, &S, RenderContext, &mut EventContext<Id>), FQuit: FnMut(&A) -> bool,

Run the event/action loop and synchronize host-rendered areas after each frame.

Source

pub async fn run_with_hooks<B, FRender, FQuit, FAfter>( &mut self, terminal: &mut Terminal<B>, render: FRender, should_quit: FQuit, after_render: FAfter, ) -> Result<()>
where B: Backend, FRender: FnMut(&mut Frame<'_>, Rect, &S, RenderContext, &mut EventContext<Id>), FQuit: FnMut(&A) -> bool, FAfter: FnMut(&mut EventBus<S, A, Id, Ctx>, &S),

Run the loop with a post-render hook after host area synchronization.

Source§

impl<S, A, E, Id, Ctx, St> HostedRuntime<S, A, E, Id, Ctx, St>
where S: 'static + EventRoutingState<Id, Ctx>, A: ActionTrait, Id: ComponentId + 'static, Ctx: BindingContext + 'static, St: RuntimeStore<S, A, E>,

Source

pub async fn run_with_effects<B, FRender, FQuit, FEffect>( &mut self, terminal: &mut Terminal<B>, render: FRender, should_quit: FQuit, handle_effect: FEffect, ) -> Result<()>
where B: Backend, FRender: FnMut(&mut Frame<'_>, Rect, &S, RenderContext, &mut EventContext<Id>), FQuit: FnMut(&A) -> bool, FEffect: FnMut(E, &mut EffectContext<'_, A>),

Run the event/action loop with effects and host area synchronization.

Source

pub async fn run_with_effect_hooks<B, FRender, FQuit, FEffect, FAfter>( &mut self, terminal: &mut Terminal<B>, render: FRender, should_quit: FQuit, handle_effect: FEffect, after_render: FAfter, ) -> Result<()>
where B: Backend, FRender: FnMut(&mut Frame<'_>, Rect, &S, RenderContext, &mut EventContext<Id>), FQuit: FnMut(&A) -> bool, FEffect: FnMut(E, &mut EffectContext<'_, A>), FAfter: FnMut(&mut EventBus<S, A, Id, Ctx>, &S),

Run the loop with effects and a post-render hook after host area synchronization.

Auto Trait Implementations§

§

impl<S, A, E, Id, Ctx, St = Store<S, A, E>> !Freeze for HostedRuntime<S, A, E, Id, Ctx, St>

§

impl<S, A, E, Id, Ctx, St = Store<S, A, E>> !RefUnwindSafe for HostedRuntime<S, A, E, Id, Ctx, St>

§

impl<S, A, E, Id, Ctx, St = Store<S, A, E>> !Send for HostedRuntime<S, A, E, Id, Ctx, St>

§

impl<S, A, E, Id, Ctx, St = Store<S, A, E>> !Sync for HostedRuntime<S, A, E, Id, Ctx, St>

§

impl<S, A, E, Id, Ctx, St> Unpin for HostedRuntime<S, A, E, Id, Ctx, St>
where St: Unpin, E: Unpin, S: Unpin, Id: Unpin, Ctx: Unpin,

§

impl<S, A, E, Id, Ctx, St> UnsafeUnpin for HostedRuntime<S, A, E, Id, Ctx, St>
where St: UnsafeUnpin,

§

impl<S, A, E, Id, Ctx, St = Store<S, A, E>> !UnwindSafe for HostedRuntime<S, A, E, Id, Ctx, St>

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.