Struct App

Source
pub struct App {
    pub flipped: bool,
    pub opts: Opts,
    pub text: String,
    /* private fields */
}
Expand description

App holds the state of the application

Fields§

§flipped: bool

This determines whether the card should show the question or the answer.

§opts: Opts

The (command line) options of the App to determine how it willl run.

§text: String

The currently entered text for Input questions. Reset when moving to a new questions.

Implementations§

Source§

impl App

Source

pub fn new(deck: Deck, opts: Opts) -> Self

Creates a new app from a deck of cards

Source

pub fn order_playables(&mut self)

Put the playable cards in order based of their score

Source

pub fn cards(&self) -> &[Card]

Returns an immutable copy of all the cards

Source

pub fn dues(&self) -> HashMap<CardIdx, Option<DateTime<Utc>>>

Returns in immutable copy of when different cards are due.

The key is garunteed to probably be an index from [Self::cards]

Source

pub fn scores(&self) -> HashMap<usize, usize>

Returns in immutable copy of each cards scores.

The key is garunteed to probably be an index from [Self::cards]

Source

pub fn circulating(&self) -> &[CardIdx]

Returns a copy of cards which are mandatorily in circulation until answered correctly

Source

pub fn flip(&mut self)

Flips the current card to show the other side.

Source

pub fn playable_range(&self) -> usize

Gets the range of cards currently being played with.

Source

pub fn shuffle(&mut self)

Shuffles the deck so you can play with different cards

Source

pub fn shuffle_all(&mut self)

Shuffles the whole deck so you can play with different cards

Source

pub fn retain_undue(&mut self)

Removes any cards which aren’t due from the deck

Source

pub fn next_card(&mut self)

Moves on to the next card

Source

pub fn card(&self) -> &Card

Gets the current card from the app.

Source

pub fn card_mut(&mut self) -> &mut Card

Gets the current card from the app.

Source

pub fn card_score(&self) -> usize

Gets the score of the current card from the app.

Source

pub fn reset_current_card_duration(&mut self)

Resets the duration of the current card.

This will index DURATIONS and work out from that how far forth it should be due.

Source

pub fn change_current_card_score(&mut self, val: isize)

Changes the score of the current card.

A card can not have a negative score. If the zeroize option is true then a negative val will set the score to zero.

Source

pub fn current_card_is_finished(&self, card: usize) -> bool

Determines if the current card still should be played or if its due date has expired.

Source

pub fn unfinished_count(&self) -> usize

Gets how many cards still need to be played.

Source

pub fn write_scores(&self) -> Result<()>

Writes the scores recursively to the relevant files, as specified in App::opts.

Source

pub fn add_scores(&mut self, scores: Scores, path: &Path)

Adds a [flashed::Scores] into an App

Source

pub fn read_scores(&mut self) -> Result<()>

Reads and applies the scores from the file or directory, as specified in App::opts

Source

pub fn get_paths(&self) -> Vec<&PathBuf>

Returns a list of all card paths in the deck

Source

pub fn scores_from_path(&self, path: &Path) -> Scores

Gets the scores for all cards with the given path

Trait Implementations§

Source§

impl Clone for App

Source§

fn clone(&self) -> App

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for App

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'a> From<&'a App> for Scores

Source§

fn from(app: &App) -> Self

Converts to this type from the input type.

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.