pub struct FalClient { /* private fields */ }
Implementations§
source§impl FalClient
impl FalClient
pub fn build_url(&self, path: &str) -> String
sourcepub fn new(credentials: ClientCredentials) -> Self
pub fn new(credentials: ClientCredentials) -> Self
Examples found in repository?
examples/stable_diffusion.rs (line 19)
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
async fn main() {
let client = FalClient::new(ClientCredentials::from_env());
let res = client
.run(
"fal-ai/stable-cascade",
serde_json::json!({
"prompt": "A large waterfall in the middle of a volcano, surrounded by lush greenery and children's playground equipment.",
}),
)
.await
.unwrap();
let output: Output = res.json::<Output>().await.unwrap();
let url = output.images[0].url.clone();
let filename = url.split('/').last().unwrap();
download_image(&url, format!("{}/{}", "images", filename).as_str())
.await
.unwrap();
}
sourcepub async fn run<T: Serialize>(
&self,
funtion_id: &str,
inputs: T,
) -> Result<Response, FalError>
pub async fn run<T: Serialize>( &self, funtion_id: &str, inputs: T, ) -> Result<Response, FalError>
Examples found in repository?
examples/stable_diffusion.rs (lines 22-27)
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
async fn main() {
let client = FalClient::new(ClientCredentials::from_env());
let res = client
.run(
"fal-ai/stable-cascade",
serde_json::json!({
"prompt": "A large waterfall in the middle of a volcano, surrounded by lush greenery and children's playground equipment.",
}),
)
.await
.unwrap();
let output: Output = res.json::<Output>().await.unwrap();
let url = output.images[0].url.clone();
let filename = url.split('/').last().unwrap();
download_image(&url, format!("{}/{}", "images", filename).as_str())
.await
.unwrap();
}
Auto Trait Implementations§
impl Freeze for FalClient
impl RefUnwindSafe for FalClient
impl Send for FalClient
impl Sync for FalClient
impl Unpin for FalClient
impl UnwindSafe for FalClient
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