1 个不稳定版本
0.1.2 | 2023年8月30日 |
---|---|
0.1.1 |
|
0.1.0 |
|
65 在 #drive
21KB
419 代码行
deta.rs
Rust 为 Deta Base 和 Drive HTTP API 提供绑定
用法
Cargo.toml
[dependencies]
deta-sdk = "0.1.2"
快速入门
use serde;
use deta::Deta;
#[derive(serde::Serialize, serde::Deserialize)]
struct User {
key: String,
name: String,
age: u8,
}
fn main() {
let deta = Deta::new("project_key");
let base = deta.base("base_name");
let drive = deta.drive("drive_name");
let user = User {
key: "user_1".to_string(),
name: "John".to_string(),
age: 20,
};
// BASE OPERATIONS
// Insert a single item
_ = base.insert(&user).unwrap();
// Get a single item
let user = base.get("user_1").unwrap();
// Get in deserialize format
let user_d = base.get_as::<User>("user_1").unwrap();
println!("{:?}", user_d);
// ...
// DRIVE OPERATIONS
// Put a single file
_ = drive.put("hello.txt", "Hello World".as_bytes(), Some("text/plain")).unwrap();
_ = drive.delete(vec!["hello.txt"]).unwrap();
// ...
}
Base
方法
-
put
(批量最大 25) -
get
(单个) -
insert
(单个) -
delete
(单个) -
update
(带有 upsert) -
fetch
(带有分页)
Drive
方法
-
put
(单个) -
get
(单个) -
delete
(单个) -
list
(带有分页
依赖
~10–19MB
~383K SLoC