supabase/lib.rs
1//! # Supabase Rust Client
2//!
3//! A comprehensive Rust client library for Supabase that provides:
4//! - Authentication (sign up, sign in, JWT handling)
5//! - Database operations (CRUD via REST API)
6//! - Storage (file upload, download, management)
7//! - Realtime subscriptions (WebSocket-based)
8//!
9//! ## Quick Start
10//!
11//! ```rust,no_run
12//! use supabase::Client;
13//! use serde::{Deserialize, Serialize};
14//!
15//! #[derive(Debug, Serialize, Deserialize)]
16//! struct Post {
17//! id: i32,
18//! title: String,
19//! content: String,
20//! }
21//!
22//! #[tokio::main]
23//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
24//! let client = Client::new("your-project-url", "your-anon-key")?;
25//!
26//! // Authenticate
27//! let _user = client.auth()
28//! .sign_in_with_email_and_password("user@example.com", "password")
29//! .await?;
30//!
31//! // Query database with proper type annotation
32//! let _posts: Vec<Post> = client.database()
33//! .from("posts")
34//! .select("*")
35//! .execute()
36//! .await?;
37//!
38//! Ok(())
39//! }
40//! ```
41
42pub mod auth;
43pub mod client;
44pub mod database;
45pub mod error;
46pub mod realtime;
47pub mod storage;
48pub mod types;
49
50pub use client::Client;
51pub use error::{Error, Result};
52
53pub use auth::Auth;
54pub use database::Database;
55pub use realtime::Realtime;
56pub use storage::Storage;
57
58pub mod prelude {
59 //! Re-exports of commonly used types and traits
60
61 pub use crate::auth::{Auth, AuthResponse, Session, User};
62 pub use crate::database::{
63 Database, DeleteBuilder, InsertBuilder, QueryBuilder, UpdateBuilder,
64 };
65 pub use crate::storage::{Bucket, FileObject, Storage};
66 pub use crate::types::{AuthConfig, DatabaseConfig, StorageConfig, SupabaseConfig};
67 pub use crate::{Client, Error, Result};
68}