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)
18async fn main() {
19 let client = FalClient::new(ClientCredentials::from_env());
20
21 let res = client
22 .run(
23 "fal-ai/stable-cascade",
24 serde_json::json!({
25 "prompt": "A large waterfall in the middle of a volcano, surrounded by lush greenery and children's playground equipment.",
26 }),
27 )
28 .await
29 .unwrap();
30
31 let output: Output = res.json::<Output>().await.unwrap();
32
33 let url = output.images[0].url.clone();
34 let filename = url.split('/').last().unwrap();
35
36 download_image(&url, format!("{}/{}", "images", filename).as_str())
37 .await
38 .unwrap();
39}
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)
18async fn main() {
19 let client = FalClient::new(ClientCredentials::from_env());
20
21 let res = client
22 .run(
23 "fal-ai/stable-cascade",
24 serde_json::json!({
25 "prompt": "A large waterfall in the middle of a volcano, surrounded by lush greenery and children's playground equipment.",
26 }),
27 )
28 .await
29 .unwrap();
30
31 let output: Output = res.json::<Output>().await.unwrap();
32
33 let url = output.images[0].url.clone();
34 let filename = url.split('/').last().unwrap();
35
36 download_image(&url, format!("{}/{}", "images", filename).as_str())
37 .await
38 .unwrap();
39}
Trait Implementations§
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