Struct initiative_core::app::App
source · pub struct App {
meta: AppMeta,
}
Expand description
The application wrapper. Its inner AppMeta
object holds metadata associated with the
application, including ephemeral storage of journal entries and the object representing the
underlying data storage.
The main methods of interest are App::command
, called when a command is run by the user,
and App::autocomplete
, called to get a list of suggestions for a given input.
Fields§
§meta: AppMeta
Implementations§
source§impl App
impl App
pub fn new(meta: AppMeta) -> App
sourcepub async fn init(&mut self) -> &'static str
pub async fn init(&mut self) -> &'static str
Initialize a running application. This is done as a separate step from the constructor because it runs asynchronously. Its purpose, in turn, is to trigger the underlying data store to initialize, which may involve opening a database connection.
sourcepub async fn command(&mut self, input: &str) -> Result<String, String>
pub async fn command(&mut self, input: &str) -> Result<String, String>
The user typed an input and pressed Enter. What happens?
On success or failure, returns a String that can be displayed back to the user.
sourcepub async fn autocomplete(&self, input: &str) -> Vec<AutocompleteSuggestion>
pub async fn autocomplete(&self, input: &str) -> Vec<AutocompleteSuggestion>
The user has updated their input and a new set of suggestions should be populated. This
consists of a Vec
of tuples; the first entry being the text that the user is suggested to
type, the second being a brief (1-3–word) description of what that input will do. Cow
is
used here to allow either String
or &'static str
, whatever is appropriate to a given
case.
Returns a maximum of 10 results.
sourcepub async fn bulk_import(&mut self, data: BackupData) -> Result<String, String>
pub async fn bulk_import(&mut self, data: BackupData) -> Result<String, String>
The part of the import flow that occurs after the user selects a file in response to the
Event::Import
.