Simple structural data modeling for Rust.
Yoshino automatically manages how the structural data should be persisted in database, so you only need to focus on your business logic.
prelude
- Prelude crate that contains core and derive exportscore
- Core data types/abstractionsderive
- Marcos for deriving code to implement schema traitsqlite
- SQLite database adaptormysql
- MySQL and MariaDB database adaptoruser
- User identity type
Simply to derive Schema from yoshino:
use yoshino_prelude::*;
#[derive(Schema)]
struct Record {
pub id: RowID,
pub title: String,
pub content: Option<String>,
pub reader: i64
}
Then you can use a Yoshino database adapter to persist the data of this struct:
let record = Record::new(...); // create a new record
let mut db =
SQLiteAdaptor::open("example_db_file")
.unwrap(); // open a SQLite db
db.insert_record(record).unwrap(); // store the record
The data can be retrieved with:
for record in adaptor.query_all::<Record>().unwrap() {
// use the data in record
}
For more usages, please refer to this document and the examples.
Copyright 2022-present Mengxiao Lin <[email protected]>.
This project is licensed under MIT License.