initiative_core/
lib.rs

1//! This crate forms the core of the initiative.sh application. It is a common dependency of the
2//! `initiative_web` crate containing the web version of the app, and the `initiative_cli` crate
3//! containing the (incomplete) terminal version.
4//!
5//! It communicates to the outside world through the [`app::App`] struct, which exposes essentially
6//! the entirety of the crate's public API (constructed using the [`app()`] function). See the
7//! documentation of these two entities for details on that API.
8
9pub mod app;
10
11pub use crate::app::{App, Event};
12pub use crate::storage::backup::BackupData;
13pub use crate::storage::{DataStore, MemoryDataStore, NullDataStore};
14pub use crate::world::thing::Thing;
15pub use uuid::Uuid;
16
17#[cfg(any(test, feature = "integration-tests"))]
18pub use utils::test_utils;
19
20#[cfg(not(feature = "integration-tests"))]
21mod command;
22#[cfg(feature = "integration-tests")]
23pub mod command;
24
25mod reference;
26mod storage;
27mod time;
28
29#[cfg(not(feature = "integration-tests"))]
30mod utils;
31#[cfg(feature = "integration-tests")]
32pub mod utils;
33
34mod world;
35
36/// Creates a new instance of the application wrapper. The `data_store` is used to save and load
37/// data from storage, and the `event_dispatcher` is a callback function invoked whenever an
38/// event occurs in-app that may require special handling by the UI. See [`Event`] for details.
39pub fn app<F: Fn(Event)>(
40    data_store: impl DataStore + 'static,
41    event_dispatcher: &'static F,
42) -> app::App {
43    let app_meta = app::AppMeta::new(data_store, event_dispatcher);
44    app::App::new(app_meta)
45}