| Crates.io | bootrust |
| lib.rs | bootrust |
| version | 0.1.0 |
| created_at | 2025-05-11 07:48:22.475103+00 |
| updated_at | 2025-05-11 07:48:22.475103+00 |
| description | An elegant macroless data access layer abstraction, simple and easy-use object-relational mapping powered by the Serde serialization framework. 一个优雅的无宏的数据访问层抽象, 由serde序列化框架提供支持的简单易用的对象关系映射 |
| homepage | |
| repository | https://github.com/tianzeshi-study/bootrust |
| max_upload_size | |
| id | 1669179 |
| size | 475,023 |
An elegant, macro-free Data Access Layer abstraction — a simple and easy-to-use ORM powered by Serde.
Cargo.toml, with no changes needed in business logic.entity_to_map and row_to_entity functions to handle special type mappings.Add the following to your project's Cargo.toml:
[dependencies]
bootrust = { version = "0.1", features = ["sqlite_async"] } # Core BOOTrust library with async sqlite support
# Run the simple example with SQLite backend
cargo run --example simple_example --features=sqlite_async
| Rust Type | Example DB Types | Serde Conversion | Notes |
|---|---|---|---|
String |
PostgreSQL: TEXTMySQL: TEXTSQLite: TEXT |
Built-in | Text type |
i32 |
PostgreSQL: INTEGERMySQL: INTSQLite: INTEGER |
Built-in | 32-bit integer |
i64 |
PostgreSQL: BIGINTMySQL: BIGINTSQLite: INTEGER |
Built-in | 64-bit integer; all SQLite integers are stored as INTEGER |
Vec<T> |
PostgreSQL: BYTEAMySQL: BLOBSQLite: BLOB |
Built-in | Binary data |
Option<T> |
Same as type T, but allows NULL |
Built-in | Optional value |
DateTime<Utc> |
PostgreSQL: BIGINTMySQL: BIGINTSQLite: TEXT / INTEGER |
#[serde(with = "chrono::serde::ts_seconds")] |
- MySQL: only supports integer (Unix timestamp) format. - PostgreSQL & SQLite: supports both ISO-8601 text and integer with Serde attributes. |
Notes:
- Due to Rust's orphan rule, this crate cannot provide a custom Serde implementation for
chrono::DateTime. If you cannot change the database column type (e.g., for existing tables), you must manually define the mapping betweenDateTime<Utc>andValue::DateTimeinentity_to_map/row_to_entity.- The MySQL driver does not support serializing
DateTime<Utc>asTEXT; it only supports integer mappings.- PostgreSQL has limited support for null types, only allowing empty values for
TEXT.
Just swap the feature flag in Cargo.toml to switch database backends.
Note: Ensure that your runtime and async driver dependencies are compatible.
[dependencies]
bootrust = { version = "0.1", features = ["postgresql_async"] }
# bootrust = { version = "0.1", features = ["mysql_async"] }
No changes to your business logic are needed—just rebuild with cargo build.
This project is licensed under the MIT license.