Giter VIP home page Giter VIP logo

rpocket's Introduction

rpocket

rpocket is an unofficial SDK for the PocketBase written in Rust. This SDK provides an easy-to-use interface for interacting with the PocketBase API, allowing developers to manage their pocketbase server and perform CRUD operations seamlessly.

Supported versions

  • v0.14.x

Features

  • Supports CRUD operations
  • MIT licensed
  • Depend on reqwest and tower package
  • In early development phase
  • Future support for realtime service

Installation

To use Rust PocketBase SDK in your Rust project, simply add the following line to your Cargo.toml file:

rpocket = "0.1.0"

Usage

Here's a simple example of how to use the Rust PocketBase SDK to fetch data from demo api:

use std::collections::HashMap;

use rpocket::{
    model::Collection, model::Record, rpocket::PocketBaseClient, service::admin::AdminAuthResponse,
    service::admin::AdminAuthWithPasswordConfig, service::crud::CRUDGetListConfig, PocketBase,
};

#[tokio::main]
async fn main() {
    let mut pocket_base = PocketBase::new("https://pocketbase.io", "en");

    let config = AdminAuthWithPasswordConfig::<HashMap<String, String>> {
        identity: "[email protected]".to_string(),
        password: "123456".to_string(),
        ..Default::default()
    };

    let result = pocket_base
        .admin()
        .auth_with_password::<AdminAuthResponse, HashMap<String, String>>(&config)
        .await;

    match result {
        Ok(response) => {
            println!("response: {:?}", response);
        }
        Err(error) => {
            println!("error: {:?}", error);
        }
    }

    let config = CRUDGetListConfig {
        ..Default::default()
    };

    let result = pocket_base
        .collection()
        .crud()
        .get_list::<Collection>(&config)
        .await;

    match result {
        Ok(response) => {
            println!("response: {:?}", response);
        }
        Err(error) => {
            println!("error: {:?}", error);
        }
    }

    let config = CRUDGetListConfig {
        ..Default::default()
    };

    let result = pocket_base
        .record("users")
        .crud()
        .get_list::<Record>(&config)
        .await;

    match result {
        Ok(response) => {
            println!("response: {:?}", response);
        }
        Err(error) => {
            println!("error: {:?}", error);
        }
    }
}

Contributing

This project is in its early stages, and contributions are welcome! If you find any bugs, please open an issue or submit a pull request. Any help in improving this SDK would be greatly appreciated.

rpocket's People

Contributors

tcmits avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.