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

source

pub fn new(meta: AppMeta) -> App

source

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.

source

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.

source

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.

source

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.

Trait Implementations§

source§

impl Debug for App

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for App

§

impl !RefUnwindSafe for App

§

impl !Send for App

§

impl !Sync for App

§

impl Unpin for App

§

impl !UnwindSafe for App

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>,

§

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>,

§

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V