async_dashscope/operation/
image2image.rs1use crate::{Client, error::Result};
2pub use output::*;
3pub use param::*;
4use secrecy::ExposeSecret;
5
6mod output;
7mod param;
8
9const IMAGE2IMAGE_PATH: &str = "/services/aigc/image2image/image-synthesis";
10
11pub struct Image2Image<'a> {
12 client: &'a Client,
13}
14
15impl<'a> Image2Image<'a> {
16 pub fn new(client: &'a Client) -> Self {
17 Self { client }
18 }
19
20 pub async fn call(&self, request: Image2imageParam) -> Result<Image2ImageOutput> {
40 let request = request
46 .upload_file_to_oss(self.client.config().api_key().expose_secret())
47 .await?;
48
49 let mut headers = self.client.config().headers();
50 headers.insert("X-DashScope-Async", "enable".parse().unwrap());
51
52 self.client
54 .post_with_headers(IMAGE2IMAGE_PATH, request, headers)
55 .await
56 }
57}