pub struct FunctionsClient { /* private fields */ }Expand description
HTTP client for Supabase Edge Functions.
Communicates with Edge Functions at /functions/v1/{function_name}.
§Example
ⓘ
use supabase_client_functions::{FunctionsClient, InvokeOptions};
use serde_json::json;
let client = FunctionsClient::new("https://your-project.supabase.co", "your-anon-key")?;
let response = client.invoke("hello", InvokeOptions::new()
.body(json!({"name": "World"}))
).await?;
let data: serde_json::Value = response.json()?;Implementations§
Source§impl FunctionsClient
impl FunctionsClient
Sourcepub fn new(supabase_url: &str, api_key: &str) -> Result<Self, FunctionsError>
pub fn new(supabase_url: &str, api_key: &str) -> Result<Self, FunctionsError>
Create a new Edge Functions client.
supabase_url is the project URL (e.g., https://your-project.supabase.co).
api_key is the Supabase anon or service_role key.
Sourcepub fn set_auth(&self, token: &str)
pub fn set_auth(&self, token: &str)
Update the default auth token for function invocations.
Subsequent invocations will use Bearer <token> unless overridden per-request.
Mirrors supabase.functions.setAuth(token).
Sourcepub async fn invoke(
&self,
function_name: &str,
options: InvokeOptions,
) -> Result<FunctionResponse, FunctionsError>
pub async fn invoke( &self, function_name: &str, options: InvokeOptions, ) -> Result<FunctionResponse, FunctionsError>
Invoke an Edge Function.
§Arguments
function_name- The name of the deployed function.options- Invocation options (body, method, headers, region, etc.).
§Errors
FunctionsError::RelayErrorif Supabase infrastructure returned an error (x-relay-error: true).FunctionsError::HttpErrorif the function returned a non-2xx status.FunctionsError::Httpon network failure.
Trait Implementations§
Source§impl Clone for FunctionsClient
impl Clone for FunctionsClient
Source§fn clone(&self) -> FunctionsClient
fn clone(&self) -> FunctionsClient
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for FunctionsClient
impl !RefUnwindSafe for FunctionsClient
impl Send for FunctionsClient
impl Sync for FunctionsClient
impl Unpin for FunctionsClient
impl UnsafeUnpin for FunctionsClient
impl !UnwindSafe for FunctionsClient
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
Mutably borrows from an owned value. Read more