Crates.io | rpocket |
lib.rs | rpocket |
version | 0.1.0 |
source | src |
created_at | 2023-04-09 10:56:15.209634 |
updated_at | 2023-04-09 10:56:15.209634 |
description | 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. |
homepage | |
repository | https://github.com/TcMits/rpocket |
max_upload_size | |
id | 834085 |
size | 176,332 |
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.
v0.14.x
reqwest
and tower
packageTo use Rust PocketBase SDK in your Rust project, simply add the following line to your Cargo.toml
file:
rpocket = "0.1.0"
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: "test@example.com".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);
}
}
}
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.