pub struct Functions { /* private fields */ }
Expand description
Edge Functions client for invoking serverless functions
§Examples
Basic function invocation:
use supabase::Client;
use serde_json::json;
let client = Client::new("your-project-url", "your-anon-key")?;
// Invoke a function with parameters
let result = client.functions()
.invoke("hello-world", Some(json!({"name": "World"})))
.await?;
println!("Function result: {}", result);
Function with custom headers:
use supabase::Client;
use serde_json::json;
use std::collections::HashMap;
let client = Client::new("your-project-url", "your-anon-key")?;
let mut headers = HashMap::new();
headers.insert("X-Custom-Header".to_string(), "custom-value".to_string());
let result = client.functions()
.invoke_with_options("my-function", Some(json!({"data": "value"})), Some(headers))
.await?;
Implementations§
Source§impl Functions
impl Functions
Sourcepub fn new(
config: Arc<SupabaseConfig>,
http_client: Arc<HttpClient>,
) -> Result<Self>
pub fn new( config: Arc<SupabaseConfig>, http_client: Arc<HttpClient>, ) -> Result<Self>
Create a new Functions instance
Sourcepub async fn invoke(
&self,
function_name: &str,
body: Option<Value>,
) -> Result<Value>
pub async fn invoke( &self, function_name: &str, body: Option<Value>, ) -> Result<Value>
Invoke an Edge Function
§Parameters
function_name
- Name of the function to invokebody
- Optional JSON body to send to the function
§Examples
use serde_json::json;
// Simple function call
let result = functions.invoke("hello", None).await?;
// Function with parameters
let result = functions.invoke("process-data", Some(json!({
"user_id": 123,
"action": "update_profile"
}))).await?;
Sourcepub async fn invoke_with_options(
&self,
function_name: &str,
body: Option<Value>,
headers: Option<HashMap<String, String>>,
) -> Result<Value>
pub async fn invoke_with_options( &self, function_name: &str, body: Option<Value>, headers: Option<HashMap<String, String>>, ) -> Result<Value>
Invoke an Edge Function with custom options
§Parameters
function_name
- Name of the function to invokebody
- Optional JSON body to send to the functionheaders
- Optional additional headers to send
§Examples
use serde_json::json;
use std::collections::HashMap;
let mut headers = HashMap::new();
headers.insert("X-API-Version".to_string(), "v1".to_string());
headers.insert("X-Custom-Auth".to_string(), "bearer token".to_string());
let result = functions.invoke_with_options(
"secure-function",
Some(json!({"sensitive": "data"})),
Some(headers)
).await?;
Sourcepub fn functions_url(&self) -> String
pub fn functions_url(&self) -> String
Get the base Functions URL
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Functions
impl !RefUnwindSafe for Functions
impl Send for Functions
impl Sync for Functions
impl Unpin for Functions
impl !UnwindSafe for Functions
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