3 个版本 (破坏性更新)

0.3.0 2021年8月3日
0.2.0 2021年8月3日
0.1.0 2021年8月1日

#10 in #user-key

自定义许可证

4KB

data-rust

Deta SDK for Rust

示例

Cargo.toml

[dependencies]
deta = "0.3.0"
serde = { version = "1.0.127", features = ["derive"] }

main.rs

use deta::base::Base;
use serde::Deserialize;

#[derive(Debug, Deserialize)]
struct User {
    key: String,
    name: String,
    age: i32,
}

fn main() {
    let base = Base::new(
        String::from("DB_NAME"),
        String::from("DB_PROJECT_KEY"),
        String::from("DB_PROJECT_ID"),
    );
    let user: User = base
        .get(String::from("krvb876h"))
        .expect("There was an error!")
        .json()
        .expect("There was an error!");

    println!("{:?}", user);
}

这将打印以下内容到控制台

User { key: "krvb876h", name: "Sarmad", age: 25 }

依赖

~4–19MB
~249K SLoC