pub struct SupabaseClient {
pub(crate) http: Client,
pub(crate) project_url: String,
pub(crate) api_key: String,
}Expand description
HTTP client for the Supabase PostgREST and Storage APIs.
Fields§
§http: Client§project_url: String§api_key: StringImplementations§
Source§impl SupabaseClient
impl SupabaseClient
Sourcepub fn new(project_url: &str, api_key: &str) -> Result<Self>
pub fn new(project_url: &str, api_key: &str) -> Result<Self>
Creates a client for a Supabase project and API key.
§Errors
Returns an error if the underlying HTTP client cannot be built.
Sourcepub fn from_env() -> Result<Self>
pub fn from_env() -> Result<Self>
Creates a client from SUPABASE_URL and SUPABASE_ANON_KEY.
§Errors
Returns an error when either variable is absent or the HTTP client cannot be built.
Sourcepub fn from_env_service_role() -> Result<Self>
pub fn from_env_service_role() -> Result<Self>
Creates an administrative client from the Supabase environment variables.
§Errors
Returns an error when SUPABASE_URL or SUPABASE_SERVICE_ROLE_KEY is absent, or the HTTP client cannot be built.
Sourcepub async fn get_json<T>(&self, path: &str, schema: &str) -> Result<T>where
T: DeserializeOwned,
pub async fn get_json<T>(&self, path: &str, schema: &str) -> Result<T>where
T: DeserializeOwned,
Fetches a PostgREST resource and decodes its JSON response.
§Errors
Returns an error when the request fails, the server rejects it, or the response cannot be decoded as T.
Sourcepub async fn get_text(&self, path: &str) -> Result<String>
pub async fn get_text(&self, path: &str) -> Result<String>
Fetches a PostgREST resource as text.
§Errors
Returns an error when the request fails or the server rejects it.
Sourcepub async fn patch<T>(&self, path: &str, body: &T) -> Result<()>where
T: Serialize,
pub async fn patch<T>(&self, path: &str, body: &T) -> Result<()>where
T: Serialize,
Applies a partial update to a PostgREST resource.
§Errors
Returns an error when serialization, transport, or the server response fails.
pub(crate) fn request(&self, method: Method, url: &str) -> RequestBuilder
fn from_env_key(key_var: &str) -> Result<Self>
fn rest_url(&self, path: &str) -> String
async fn send_get(&self, url: &str, schema: Option<&str>) -> Result<Response>
Trait Implementations§
Source§impl Clone for SupabaseClient
impl Clone for SupabaseClient
Source§fn clone(&self) -> SupabaseClient
fn clone(&self) -> SupabaseClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for SupabaseClient
impl !RefUnwindSafe for SupabaseClient
impl Send for SupabaseClient
impl Sync for SupabaseClient
impl Unpin for SupabaseClient
impl UnsafeUnpin for SupabaseClient
impl !UnwindSafe for SupabaseClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more