使用旧的 Rust 2015
0.1.2 |
|
---|---|
0.1.1 |
|
0.1.0 |
|
#13 在 #简化
15KB
162 代码行
query
概述
query 是一个简化的单表数据库库
示例
// get some data to work with
let data = (0..10).collect();
// write the data to disk
let mut db = DB::create("test.db", data)
.expect("can't create 'test.db'");
// change the data in memory
db.iter_mut()
.for_each(|i| *i * 2);
// apply the changes
db.apply()
.expect("can't update 'test.db'");
// delete the data in memory
drop(db);
// read the database from memory
let db = DB::load("test.db")
.expect("can't read 'test.db'");
// all values have been multiplied by 10
assert_eq!(db.to_vec(), (0..100).step_by(10).collect());
lib.rs
:
query 是一个简化的单表数据库
此软件包提供非常简单数据库的功能,您只能有一个数据库中的表,您不能就地更改数据,必须将整个数据库加载到内存中。但它非常简单。
示例
#
// get some data to work with
let data = (0..10).collect();
// write the data to disk
let mut db = DB::create("test.db", data)
.expect("can't create 'test.db'");
// change the data in memory
db.iter_mut()
.for_each(|i| *i * 2);
// apply the changes
db.apply()
.expect("can't update 'test.db'");
// delete the data in memory
drop(db);
// read the database from memory
let db = DB::load("test.db")
.expect("can't read 'test.db'");
// all values have been multiplied by 10
assert_eq!(db.to_vec(), (0..100).step_by(10).collect());
依赖项
~1–1.6MB
~30K SLoC