Crate pixeluvw_supabase

Crate pixeluvw_supabase 

Source
Expand description

§pixeluvw_supabase

A production-ready, high-performance Rust SDK for Supabase.

Designed for reliability and improved developer experience, this crate provides a strongly-typed, fluent interface for interacting with the entire Supabase stack (Database, Auth, Realtime, Storage, and Edge Functions).

Note: This SDK is currently in Beta. APIs are stable but may evolve.

§✨ Features

  • 🚀 Database: Full PostgREST support with a fluent query builder, 25+ filters, and strong typing.
  • 🔮 Schema Introspection: Unique capability to fetch remote schema metadata at runtime and generate Rust structs.
  • 🔐 Auth: Complete authentication suite including Email/Password, OAuth, OTP, MFA, and Admin API.
  • ⚡ Realtime: Robust WebSocket client for listening to database changes (INSERT, UPDATE, DELETE), presence, and broadcast.
  • 📦 Storage: Simple API for file uploads, downloads, and signed URL generation.
  • serverless Functions: Invoke Edge Functions seamlessly.
  • 🛡️ Enterprise Ready: Built-in middleware support, automatic retries with exponential backoff, and robust error handling.

§🚀 Quick Start

§A. Setup Environment

Create a .env file (ensure it’s in your .gitignore):

SUPABASE_URL=https://your-project.supabase.co
SUPABASE_KEY=your-anon-key

§B. Basic Usage

use pixeluvw_supabase::{supabase, SupabaseClient};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    dotenv::dotenv().ok();

    // Initialize the client (automatically loads from env)
    let client = supabase!()?;

    // Perform a query
    let users: Vec<serde_json::Value> = client
        .from("users")
        .select("*")
        .eq("status", "active")
        .limit(5)
        .execute()
        .await?;

    println!("Users: {:?}", users);

    Ok(())
}

§Security

Never hardcode credentials! Use environment variables:

  • SUPABASE_URL — Your project URL
  • SUPABASE_KEY — Your anon or service key
  • Add .env to .gitignore

Modules§

prelude

Macros§

supabase
Initialize a SupabaseClient with less boilerplate.

Structs§

AuthService
Authentication service for Supabase.
Bucket
ClientConfig
Configuration for the Supabase client.
ColumnSchema
FileSessionStore
A simple file-based session store.
FunctionsClient
Client for invoking Supabase Edge Functions.
MemorySessionStore
A thread-safe in-memory session store (mostly for testing).
QueryBuilder
A fluent query builder for constructing Supabase PostgREST queries.
RealtimeChannel
A handle to a subscribed Realtime channel.
RealtimeChannelBuilder
RealtimeClient
RealtimeMessage
RequestContext
Middleware context passed through the request lifecycle.
Schema
Represents the Database Schema based on PostgREST OpenAPI spec.
Session
Authentication session containing tokens and user info.
StorageBucket
A handle to a specific storage bucket.
StorageClient
Storage client for Supabase file operations.
SupabaseClient
SupabaseClientBuilder
Builder for SupabaseClient.
TableSchema
UploadedFile
User
Supabase user profile.

Enums§

ConnectionState
Connection state for realtime channels.
OtpType
OTP (One-Time Password) types for authentication.
PostgresEvent
Provider
OAuth providers supported by Supabase.
SignUpResult
Result of a sign-up operation.
SupaError
Unified error type for all Supabase SDK operations.

Traits§

Middleware
Middleware trait for intercepting requests and responses.
SessionStore
Trait for persisting sessions.

Type Aliases§

Result
A specialized Result type for Supabase operations.