Crates.io | suparust |
lib.rs | suparust |
version | 0.3.0 |
source | src |
created_at | 2024-10-16 15:42:04.895066 |
updated_at | 2024-11-23 11:16:23.702961 |
description | Supabase client for Rust with support for WASM |
homepage | |
repository | https://github.com/strykejern/suparust |
max_upload_size | |
id | 1411947 |
size | 102,222 |
This is a library for interfacing with projects hosted using Supabase.
The library is in early development, so expect breaking API changes to occur.
The goal is to support as much of the Supabase API as possible. Currently, the following features are supported:
The project supports both the stable-x86_64-unknown-linux-gnu
and wasm32-unknown-unknown
targets.
More targets might also work, but WASM is actively targeted for this crate.
cargo add suparust
let client = suparust::Supabase::new(
"https://your.postgrest.endpoint",
"your_api_key",
None,
suparust::SessionChangeListener::Ignore);
client.login_with_email(
"myemail@example.com",
"mypassword").await?;
#[derive(serde::Deserialize)]
struct MyStruct {
id: i64,
field: String
}
// Postgrest example (see postgrest crate for more details on API)
let table_contents = client
.from("your_table")
.await?
.select("*")
.execute()
.await?
.json::<Vec<MyStruct> > ();
// Storage example
use suparust::storage::object::*;
let list_request = ListRequest::new("my_folder".to_string())
.limit(10)
.sort_by("my_column", SortOrder::Ascending);
let objects = client
.storage()
.await?
.object()
.list("my_bucket", list_request)
.await?;
let object_names = objects
.iter()
.map(|object| object.name.clone());
let mut downloaded_objects = vec![];
for object in objects {
let downloaded = client
.storage()
.await?
.object()
.get_one("my_bucket", &object.name)
.await?;
downloaded_objects.push(downloaded);
}
More examples will come as the library matures.
Contributions are welcome. Please try to add tests for any new features or bug fixes.
As the library is in early development, please feel free to suggest refactorings or improvements to the API.
Some goals for the project:
postgrest
crate for PostgREST)SPDX-License-Identifier: Apache-2.0 OR MIT