pub struct LocalPracticeStats { /* private fields */ }Expand description
An implementation of PracticeStats backed by SQLite.
Implementations§
Source§impl LocalPracticeStats
impl LocalPracticeStats
Sourcepub fn new_from_disk(db_path: &str) -> Result<LocalPracticeStats>
pub fn new_from_disk(db_path: &str) -> Result<LocalPracticeStats>
A constructor taking the path to a database file.
Trait Implementations§
Source§impl PracticeStats for LocalPracticeStats
impl PracticeStats for LocalPracticeStats
Source§fn get_scores(
&self,
exercise_id: Ustr,
num_scores: usize,
) -> Result<Vec<ExerciseTrial>, PracticeStatsError>
fn get_scores( &self, exercise_id: Ustr, num_scores: usize, ) -> Result<Vec<ExerciseTrial>, PracticeStatsError>
Retrieves the last
num_scores scores of a particular exercise. The scores are returned in
descending order according to the timestamp.Source§fn record_exercise_score(
&mut self,
exercise_id: Ustr,
score: MasteryScore,
timestamp: i64,
) -> Result<(), PracticeStatsError>
fn record_exercise_score( &mut self, exercise_id: Ustr, score: MasteryScore, timestamp: i64, ) -> Result<(), PracticeStatsError>
Records the score assigned to the exercise in a particular trial. Therefore, the score is a
value of the
MasteryScore enum instead of a float. Only units of type UnitType::Exercise
should have scores recorded. However, the enforcement of this requirement is left to the
caller.Source§fn trim_scores(&mut self, num_scores: usize) -> Result<(), PracticeStatsError>
fn trim_scores(&mut self, num_scores: usize) -> Result<(), PracticeStatsError>
Deletes all the exercise trials except for the last
num_scores with the aim of keeping the
storage size under check.Source§fn remove_scores_with_prefix(
&mut self,
prefix: &str,
) -> Result<(), PracticeStatsError>
fn remove_scores_with_prefix( &mut self, prefix: &str, ) -> Result<(), PracticeStatsError>
Removes all the scores from the units that match the given prefix.
Auto Trait Implementations§
impl Freeze for LocalPracticeStats
impl !RefUnwindSafe for LocalPracticeStats
impl Send for LocalPracticeStats
impl Sync for LocalPracticeStats
impl Unpin for LocalPracticeStats
impl UnsafeUnpin for LocalPracticeStats
impl !UnwindSafe for LocalPracticeStats
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more