deta

Crates.iodeta
lib.rsdeta
version0.3.0
sourcesrc
created_at2021-08-01 14:48:55.907133
updated_at2021-08-03 00:38:46.57251
descriptionDeta SDK for Rust
homepagehttps://github.com/sarmadgulzar/rust-deta
repositoryhttps://github.com/sarmadgulzar/rust-deta
max_upload_size
id430033
size5,095
Sarmad Gulzar (sarmadgulzar)

documentation

https://github.com/sarmadgulzar/rust-deta

README

data-rust

Deta SDK for Rust

Example:

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);
}

This will print the following to the console:

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

cargo fmt