Struct App

Source
pub struct App<State> { /* private fields */ }

Implementations§

Source§

impl<State> App<State>
where State: 'static + Default,

Source

pub fn new(handle: Handle) -> App<State>

Examples found in repository?
examples/todo.rs (line 352)
347pub fn main() -> Result<(), ()> {
348
349    let mut core = Core::new().unwrap();
350    let handle = core.handle();
351
352    let mut app = App::new(handle);
353    setup(&mut app);
354
355    let handle = core.handle();
356    handle.spawn(app.dispatch(ShowMenu).map(|_| ()).map_err(|_| ()));
357
358    let std_in_ch = spawn_stdin_stream_unbounded();
359    core.run(std_in_ch.for_each(|m| {
360        app.dispatch(Input(m)).map(|_| ()).map_err(|_| ())
361    }))?;
362
363    Ok(())
364}
Source

pub fn default_interceptors(&self) -> Vec<Box<dyn Interceptor<Error = ()>>>

Source

pub fn register_event<E: 'static + Event<()>>(&mut self)

Examples found in repository?
examples/todo.rs (line 341)
340fn setup(app: &mut App<AppState>) {
341    app.register_event::<ShowPrompt>();
342    app.register_event::<ShowMenu>();
343    app.register_event::<ShowTodos>();
344    app.register_event_with::<Input>(vec![Box::new(ShowPrompt)]);
345}
Source

pub fn register_event_with<E: 'static + Event<()>>( &mut self, interceptors: Vec<Box<dyn Interceptor<Error = ()>>>, )

Examples found in repository?
examples/todo.rs (line 344)
340fn setup(app: &mut App<AppState>) {
341    app.register_event::<ShowPrompt>();
342    app.register_event::<ShowMenu>();
343    app.register_event::<ShowTodos>();
344    app.register_event_with::<Input>(vec![Box::new(ShowPrompt)]);
345}
Source

pub fn dispatch<E: 'static + Event<()>>(&mut self, e: E) -> impl Future

Examples found in repository?
examples/todo.rs (line 356)
347pub fn main() -> Result<(), ()> {
348
349    let mut core = Core::new().unwrap();
350    let handle = core.handle();
351
352    let mut app = App::new(handle);
353    setup(&mut app);
354
355    let handle = core.handle();
356    handle.spawn(app.dispatch(ShowMenu).map(|_| ()).map_err(|_| ()));
357
358    let std_in_ch = spawn_stdin_stream_unbounded();
359    core.run(std_in_ch.for_each(|m| {
360        app.dispatch(Input(m)).map(|_| ()).map_err(|_| ())
361    }))?;
362
363    Ok(())
364}

Auto Trait Implementations§

§

impl<State> Freeze for App<State>

§

impl<State> !RefUnwindSafe for App<State>

§

impl<State> !Send for App<State>

§

impl<State> !Sync for App<State>

§

impl<State> Unpin for App<State>

§

impl<State> !UnwindSafe for App<State>

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

impl<T> Any for T
where T: Any,