pub struct IFlowClient { /* private fields */ }Expand description
Main client for bidirectional communication with iFlow
This client handles the full lifecycle of communication with iFlow, including process management, connection handling, and message passing.
Implementations§
Source§impl IFlowClient
impl IFlowClient
Sourcepub fn new(options: Option<IFlowOptions>) -> Self
pub fn new(options: Option<IFlowOptions>) -> Self
Sourcepub async fn connect(&mut self) -> Result<()>
pub async fn connect(&mut self) -> Result<()>
Connect to iFlow
Establishes a connection to iFlow, starting the process if auto_start_process is enabled. This method handles all the necessary setup for communication via stdio or WebSocket.
§Returns
Ok(())if the connection was successfulErr(IFlowError)if the connection failed
Sourcepub async fn send_message(
&mut self,
text: &str,
_files: Option<Vec<&Path>>,
) -> Result<()>
pub async fn send_message( &mut self, text: &str, _files: Option<Vec<&Path>>, ) -> Result<()>
Send a message to iFlow
Sends a text message to iFlow and handles the complete request-response cycle. This method initializes the connection, creates a new session, sends the prompt, and waits for completion before returning.
§Arguments
text- The text message to send to iFlow_files- Optional files to send (currently not implemented)
§Returns
Ok(())if the message was sent successfullyErr(IFlowError)if there was an error
Sourcepub async fn interrupt(&self) -> Result<()>
pub async fn interrupt(&self) -> Result<()>
Interrupt the current message generation
Sends an interrupt signal to stop the current message generation. This is useful for canceling long-running requests.
§Returns
Ok(())if the interrupt was sent successfullyErr(IFlowError)if there was an error
Sourcepub fn messages(&self) -> MessageStream
pub fn messages(&self) -> MessageStream
Receive messages from iFlow
Returns a stream of messages from iFlow that can be used with async iteration.
§Returns
A MessageStream that implements futures::Stream
Sourcepub async fn receive_message(&self) -> Result<Option<Message>>
pub async fn receive_message(&self) -> Result<Option<Message>>
Receive a single message (convenience method)
Waits for and returns the next message from iFlow.
§Returns
Ok(Some(Message))if a message was receivedOk(None)if the channel is closedErr(IFlowError)if there was an error
Sourcepub async fn disconnect(&mut self) -> Result<()>
pub async fn disconnect(&mut self) -> Result<()>
Disconnect from iFlow
Cleans up the connection to iFlow and stops the process if it was started by this client. This method ensures proper cleanup of resources.
§Returns
Ok(())if the disconnection was successfulErr(IFlowError)if there was an error