pub struct ComfyUIClient { /* private fields */ }Expand description
A client for interacting with the ComfyUI service.
This client provides methods to fetch history, prompts, views, and to upload images.
Implementations§
Source§impl ComfyUIClient
impl ComfyUIClient
Sourcepub async fn get_history(
&self,
prompt_id: &str,
) -> ClientResult<Option<History>>
pub async fn get_history( &self, prompt_id: &str, ) -> ClientResult<Option<History>>
Retrieves the history for a specified prompt.
Sends a GET request to the history/{prompt_id} endpoint and parses the
returned history data.
§Parameters
prompt_id: The ID of the prompt whose history is being requested.
§Returns
An optional History object wrapped in a ClientResult. Returns
None if the history is not found.
Sourcepub async fn get_prompt(&self) -> ClientResult<PromptInfo>
pub async fn get_prompt(&self) -> ClientResult<PromptInfo>
Retrieves the current prompt information.
Sends a GET request to the prompt endpoint and returns the parsed
PromptInfo data.
§Returns
A PromptInfo object on success, or an error.
Sourcepub async fn get_view(&self, file_info: &FileInfo) -> ClientResult<Bytes>
pub async fn get_view(&self, file_info: &FileInfo) -> ClientResult<Bytes>
Retrieves view data corresponding to the provided file information.
Sends a GET request to the view endpoint, including the file
information as query parameters.
§Parameters
file_info: AFileInfoobject containing details about the file.
§Returns
The response as a Bytes object on success, or an error.
Sourcepub async fn post_prompt(
&self,
prompt: impl Into<Prompt<'_>>,
) -> ClientResult<PromptStatus>
pub async fn post_prompt( &self, prompt: impl Into<Prompt<'_>>, ) -> ClientResult<PromptStatus>
Sends a prompt in JSON format.
Constructs the request payload (including the client ID and prompt data)
and sends a POST request to the prompt endpoint.
§Parameters
prompt: representing the prompt data.
§Returns
A PromptStatus object on success, or an error.
Sourcepub async fn upload_image(
&self,
body: impl Into<Body>,
info: &FileInfo,
overwrite: bool,
) -> ClientResult<FileInfo>
pub async fn upload_image( &self, body: impl Into<Body>, info: &FileInfo, overwrite: bool, ) -> ClientResult<FileInfo>
Uploads an image.
Constructs a multipart form containing the image data and file
information, then sends a POST request to the upload/image endpoint.
§Parameters
body: The image data, convertible into aBody.info: AFileInfoobject containing details about the image file.overwrite: A boolean indicating whether to overwrite an existing file.
§Returns
An updated FileInfo object on success, or an error.