pub enum ChatResponse<RESP, ITEM>where
RESP: DeserializeOwned,
ITEM: DeserializeOwned,{
Full(RESP),
Stream(JsonStream<ITEM>),
}Expand description
Represents a chat response which can either be a full response or a stream of items.
This enum is generic over the response type RESP and the item type ITEM.
§Variants
Full(RESP): Represents a complete response of typeRESP.Stream(JsonStream<ITEM>): Represents a stream of items of typeITEM.
§Type Parameters
RESP: The type of the full response. Must implementDeserializeOwned.ITEM: The type of the items in the stream. Must implementDeserializeOwned.
§Methods
must_response(self) -> RESP: Consumes the enum and returns the full response if it is theFullvariant. Panics if it is theStreamvariant.must_stream(self) -> JsonStream<ITEM>: Consumes the enum and returns the stream if it is theStreamvariant. Panics if it is theFullvariant.
Variants§
Full(RESP)
Stream(JsonStream<ITEM>)
Implementations§
Source§impl<RESP, ITEM> ChatResponse<RESP, ITEM>where
RESP: DeserializeOwned,
ITEM: DeserializeOwned,
impl<RESP, ITEM> ChatResponse<RESP, ITEM>where
RESP: DeserializeOwned,
ITEM: DeserializeOwned,
pub fn must_response(self) -> RESP
pub fn must_stream(self) -> JsonStream<ITEM>
Auto Trait Implementations§
impl<RESP, ITEM> Freeze for ChatResponse<RESP, ITEM>where
RESP: Freeze,
impl<RESP, ITEM> !RefUnwindSafe for ChatResponse<RESP, ITEM>
impl<RESP, ITEM> Send for ChatResponse<RESP, ITEM>where
RESP: Send,
impl<RESP, ITEM> !Sync for ChatResponse<RESP, ITEM>
impl<RESP, ITEM> Unpin for ChatResponse<RESP, ITEM>where
RESP: Unpin,
impl<RESP, ITEM> !UnwindSafe for ChatResponse<RESP, ITEM>
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