Crate pocketbase_rs

Crate pocketbase_rs 

Source
Expand description

pocketbase-rs is a Rust wrapper around PocketBase’s REST API.

§Usage

use std::error::Error;

use pocketbase_rs::{PocketBase, Collection, RequestError};
use serde::Deserialize;

#[derive(Default, Deserialize, Clone)]
struct Article {
    title: String,
    content: String,
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    let mut pb = PocketBase::new("http://localhost:8090");

    let auth_data = pb
        .collection("users")
        .auth_with_password("YOUR_EMAIL_OR_USERNAME", "YOUR_PASSWORD")
        .await?;

    let article: Article = pb
        .collection("articles")
        .get_one::<Article>("record_id_123")
        .call()
        .await?;

    println!("Article Title: {}", article.title);

    Ok(())
}

Re-exports§

pub use error::*;

Modules§

error
Various errors module.

Structs§

AuthStore
Stores authentication details for a PocketBase user.
AuthStoreRecord
Represents the details of an authenticated user’s record.
Collection
Represents a specific collection in a PocketBase database.
Form
An async multipart/form-data request.
Part
A field in a multipart form.
PocketBase
A PocketBase client for sending requests to a PocketBase instance.
RecordList
Represents a paginated list of records retrieved from a PocketBase collection.