pub struct Driver<'e, 's> { /* private fields */ }
Expand description
A system to drive user interactions forward by providing a re-entrant polling architecture. The caller should call .next()
to get the next question/answer pair, providing the user’s response for the previous question so the driver can update the set
as necessary. This architecture allows the caller much greater control over the order of execution and display than an interface
type opaquely driven by this library would.
Implementations§
source§impl<'e, 's> Driver<'e, 's>
impl<'e, 's> Driver<'e, 's>
sourcepub fn set_target(&mut self, target: CardType) -> &mut Self
pub fn set_target(&mut self, target: CardType) -> &mut Self
Sets a specific type of card that this driver will exclusively target. By default, drivers target all cards.
sourcepub fn set_max_count(&mut self, count: u32) -> &mut Self
pub fn set_max_count(&mut self, count: u32) -> &mut Self
Sets a maximum number of elements to be reviewed through this driver. This can be useful for long-term learning, in which you only want to review, say, 30 cards per day.
Obviously, if there are not enough cards to reach this maximum count, the driver will stop before the count is reached, and will not go back to the beginning.
sourcepub fn no_mark_starred(&mut self) -> &mut Self
pub fn no_mark_starred(&mut self) -> &mut Self
If this driver is being used to run a test, prevents cards the user gets wrong from being automatically starred.
sourcepub fn no_mark_unstarred(&mut self) -> &mut Self
pub fn no_mark_unstarred(&mut self) -> &mut Self
If this driver is being used to run a test, prevents cards the user gets right from being unstarred if they were previously starred.
This is especially useful when there are a small number of cards that the user is getting wrong consistently, which they want to continue keeping track of, while also still reviewing them many times.
sourcepub fn no_mutate_difficulty(&mut self) -> &mut Self
pub fn no_mutate_difficulty(&mut self) -> &mut Self
If this driver is being used to run a learning session, prevents the learning method from marking cards as difficult, or from downgrading cards currently marked as difficult to no longer difficult.
Since the difficult
metadatum is almost entirely internal, there are generally very few scenarios in which this behaviour is desired.
sourcepub fn get_count(&self) -> u32
pub fn get_count(&self) -> u32
Gets the number of cards that have been reviewed by this driver so far.
sourcepub fn first(&mut self) -> Result<Option<SlimCard>>
pub fn first(&mut self) -> Result<Option<SlimCard>>
Gets the first question/answer pair of this run. While it is perfectly safe to run this at any time, it is semantically nonsensical to run this more than once, as Forn’s internals will become completely useless. If you want to display each card to the user only once, irrespective of the metadata attached to it, you should instantiate the driver for a test, rather than a learning session.
This will return None
if there are no more cards with non-zero weightings, in which case the learn or test
session described by this driver is complete. (If progress is not cleared, this could easily happen with a
.first()
call.)
This will automatically continue the most recent session of either learning or testing, if there is one.
sourcepub fn allowed_responses(&self) -> &[String]
pub fn allowed_responses(&self) -> &[String]
Provides the allowed responses for this learn method (or for the test, if this driver is being used for
a test), in the order they were defined. The argument to .next()
must be an element in the list this
returns.
sourcepub fn next(&mut self, response: String) -> Result<Option<SlimCard>>
pub fn next(&mut self, response: String) -> Result<Option<SlimCard>>
Gets the next question/answer pair, given a response to the last question/answer. If this is the first,
you should call .first()
instead, as calling this will lead to an error. Note that the provided response
must be identical to one of the responses defined by the method in use (these can be found with .allowed_responses()
).
sourcepub fn save_set_to_json(&self) -> Result<String>
pub fn save_set_to_json(&self) -> Result<String>
Saves the underlying set to JSON. This should generally be called between each presentation of a card to ensure the user does not lose their progress.