Skip to main content

StreamInvocation

Struct StreamInvocation 

Source
pub struct StreamInvocation<B: StreamBridge> { /* private fields */ }
Expand description

Caller-owned invocation and progress. Cancellation retains pending state writes/events; a started upstream send is never implicitly repeated.

Implementations§

Source§

impl<B: StreamBridge> StreamInvocation<B>

Source

pub fn original_request(&self) -> &B::ClientRequest

Source

pub fn target_request(&self) -> &B::NativeRequest

Source

pub fn send_started(&self) -> bool

Source

pub fn report(&self) -> &Report

Source

pub fn native_metadata(&self) -> Option<&WireResponse<()>>

Source

pub fn last_native_event(&self) -> Option<&B::NativeEvent>

Source

pub fn native_result( &self, ) -> Option<&<<B as StreamBridge>::NativeEvent as NativeEvent>::Full>

Source

pub fn client_result( &self, ) -> Option<&<<B as StreamBridge>::ClientEvent as NativeEvent>::Full>

Source

pub fn rejected_response(&self) -> Option<&WireResponse<Bytes>>

Source

pub async fn start<U: Upstream, S: StateStore>( &mut self, upstream: &U, target: &U::Target, state: &GenerationStateAccess<'_, S>, ) -> Result<StreamStart, TransformError>

Source§

impl<B: StreamBridge> StreamInvocation<B>

Source

pub async fn collect<S: StateStore>( &mut self, state: &GenerationStateAccess<'_, S>, ) -> Result<GenerationOutcome<<<B as StreamBridge>::ClientEvent as NativeEvent>::Full>, TransformError>

Collect the mapped stream into its concrete complete client wire response. The host calls start once first. This does not perform another POST.

Source

pub async fn next<S: StateStore>( &mut self, state: &GenerationStateAccess<'_, S>, ) -> Result<Option<StreamChunk<B::ClientEvent>>, TransformError>

Returns the next encoded client event. No alias is persisted before it is yielded: an emitted ID is either the upstream’s own or a per-request alias, and the only state writes happen once, at the end of the stream. Cancellation retains a prepared event.

Source§

impl StreamInvocation<GeminiToResponsesStream>

Source§

impl StreamInvocation<ResponsesToGeminiStream>

Source§

impl<B: StreamBridge<NativeEvent = StreamEvent, NativeRequest = GenerateContentRequestBody>> StreamInvocation<B>

Source

pub async fn start_websocket<'a, S: StateStore>( &'a mut self, session: &'a mut GenerationWsSession, state: &GenerationStateAccess<'_, S>, ) -> Result<GenerationWsTurn<'a, B>, TransformError>

Sends response.create at most once. The invocation and the connection must both have been prepared against this state.

Source

pub async fn start_websocket_on_lane<'a, S: StateStore>( &'a mut self, session: &'a mut GenerationWsSession, lane: Option<String>, state: &GenerationStateAccess<'_, S>, ) -> Result<GenerationWsTurn<'a, B>, TransformError>

Source§

impl<B: StreamBridge<ClientEvent = StreamEvent>> StreamInvocation<B>

Source

pub fn responses_websocket_output(&mut self) -> Result<(), TransformError>

Select bare, individually bounded JSON server messages before HTTP start. Each returned nonempty chunk is exactly one WebSocket Text payload.

Source

pub fn responses_websocket_output_on_lane( &mut self, lane: Option<String>, ) -> Result<(), TransformError>

Auto Trait Implementations§

§

impl<B> !Freeze for StreamInvocation<B>

§

impl<B> !RefUnwindSafe for StreamInvocation<B>

§

impl<B> !Sync for StreamInvocation<B>

§

impl<B> !UnwindSafe for StreamInvocation<B>

§

impl<B> Send for StreamInvocation<B>

§

impl<B> Unpin for StreamInvocation<B>

§

impl<B> UnsafeUnpin for StreamInvocation<B>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ResourceSend for T
where T: Send + ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.