SM-2
Rust crate for the classic SM-2 algorithm for spaced repetition scheduling.
Table of Contents
Installation
You can install the sm-2 crate from crates.io [link] using cargo:
Quickstart
use Utc; // chrono
use ;
Serialization
Card and ReviewLog variables are json-serializable for easy database storage and network requests
use ;
// ...
// serialize before storage / request
let card_json: String = card.to_json.unwrap;
let review_log_json: String = review_log.to_json.unwrap;
println!;
// > {"card_id":1755476939756,"n":1,"ef":2.6,"i":1,"due":"2025-08-19T00:28:59.756421Z","needs_extra_review":false}
println!;
// > {"card_id":1755476939756,"rating":5,"review_datetime":"2025-08-18T00:28:59.756451Z","review_duration":null}
// deserialize after storage / request
let new_card: Card = from_json.unwrap;
let new_review_log: ReviewLog = from_json.unwrap;
Versioning
This package is currently unstable and adheres to the following versioning scheme:
- Minor version will increase when a backward-incompatible change is introduced.
- Patch version will increase when a bug is fixed or a new feature is added.
Once this package is considered stable, the Major version will be bumped to 1.0.0 and will follow semver.