#base #drive #deta #http-api #bindings #client

yanked deta-sdk

A Rust client for Deta Base

1 unstable release

0.1.2 Aug 30, 2023
0.1.1 Aug 30, 2023
0.1.0 Aug 30, 2023

#65 in #drive

MIT license

21KB
419 lines

deta.rs

Rust bindings for the Deta Base and Drive HTTP API

Usage

Cargo.toml

[dependencies]
deta-sdk = "0.1.2"

Quickstart

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

Methods

  • put (batch max 25)
  • get (single)
  • insert (single)
  • delete (single)
  • update (with upsert)
  • fetch (with pagination)

Drive

Methods

  • put (single)
  • get (single)
  • delete (single)
  • list (with pagination

Dependencies

~11–20MB
~372K SLoC