pub struct ResponseHandler<T> { /* private fields */ }Expand description
One-shot async response handler. Exactly one of the successful/failed handlers passed to an API call is consumed.
Implementations§
Source§impl<T> ResponseHandler<T>
impl<T> ResponseHandler<T>
Sourcepub fn new<F, Fut>(handler: F) -> Selfwhere
F: FnOnce(ResponseHandlerInput) -> Fut + Send + 'static,
Fut: Future<Output = Result<ResponseHandlerOutput<T>, AiMuxError>> + Send + 'static,
pub fn new<F, Fut>(handler: F) -> Selfwhere
F: FnOnce(ResponseHandlerInput) -> Fut + Send + 'static,
Fut: Future<Output = Result<ResponseHandlerOutput<T>, AiMuxError>> + Send + 'static,
Create a handler from an async closure.
Sourcepub fn streaming(self) -> Self
pub fn streaming(self) -> Self
Mark the handler as streaming: it hands the response body onward as a stream instead of reading it to completion, so the per-exchange response timeout must not cover body consumption.
Sourcepub async fn handle(
self,
input: ResponseHandlerInput,
) -> Result<ResponseHandlerOutput<T>, AiMuxError>
pub async fn handle( self, input: ResponseHandlerInput, ) -> Result<ResponseHandlerOutput<T>, AiMuxError>
Consume the handler and process one response.
§Errors
Returns the handler’s contextual API, parse, or caller-abort failure.
Auto Trait Implementations§
impl<T> !RefUnwindSafe for ResponseHandler<T>
impl<T> !Sync for ResponseHandler<T>
impl<T> !UnwindSafe for ResponseHandler<T>
impl<T> Freeze for ResponseHandler<T>where
Box<dyn FnOnce(ResponseHandlerInput) -> Pin<Box<dyn Future<Output = Result<ResponseHandlerOutput<T>, AiMuxError>> + Send>> + Send>: Freeze,
impl<T> Send for ResponseHandler<T>where
Box<dyn FnOnce(ResponseHandlerInput) -> Pin<Box<dyn Future<Output = Result<ResponseHandlerOutput<T>, AiMuxError>> + Send>> + Send>: Send,
impl<T> Unpin for ResponseHandler<T>where
Box<dyn FnOnce(ResponseHandlerInput) -> Pin<Box<dyn Future<Output = Result<ResponseHandlerOutput<T>, AiMuxError>> + Send>> + Send>: Unpin,
impl<T> UnsafeUnpin for ResponseHandler<T>where
Box<dyn FnOnce(ResponseHandlerInput) -> Pin<Box<dyn Future<Output = Result<ResponseHandlerOutput<T>, AiMuxError>> + Send>> + Send>: UnsafeUnpin,
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