pub trait ABQuery {
const QUERY: &'static str;
// Required method
fn from_row(row: &Row<'_>) -> Self;
}
Expand description
A trait for standardizing how types are created from the Apple Books databases.
This trait allows for instances to be created generically over the rows of their respective
databases BKLibrary*.sqlite
and AEAnnotation*.sqlite
.
The ABQuery::from_row()
and ABQuery::QUERY
methods are strongly coupled in that the
declared rows in the SELECT
statement must map directly to the rusqlite
’s Row::get()
method e.g. the first row of the SELECT
statement maps to row.get(0)
etc. The unwrap
on
the Row::get()
methods will panic if the index is out of range or the there’s a type mismatch
to the struct field it’s been mapped to.
The databases seem to be related via a UUID field.
Book ZBKLIBRARYASSET.ZASSETID ─────────┐
Annotation ZAEANNOTATION.ZANNOTATIONASSETID ─┘
Required Associated Constants§
Sourceconst QUERY: &'static str
const QUERY: &'static str
The query to retrieve rows from the database. The rows are then passed
into ABQuery::from_row()
to create instances of the implementing
type.
Required Methods§
Sourcefn from_row(row: &Row<'_>) -> Self
fn from_row(row: &Row<'_>) -> Self
Constructs an instance of the implementing type from a rusqlite::Row
.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.