Struct ProcedureStream

Source
pub struct ProcedureStream { /* private fields */ }
Expand description

TODO

Implementations§

Source§

impl ProcedureStream

Source

pub fn from_stream<T, S>(s: S) -> ProcedureStream
where S: Stream<Item = Result<T, ProcedureError>> + Send + 'static, T: Serialize + Send + Sync + 'static,

TODO

Source

pub fn from_future<T, F>(f: F) -> ProcedureStream
where F: Future<Output = Result<T, ProcedureError>> + Send + 'static, T: Serialize + Send + Sync + 'static,

TODO

Source

pub fn from_future_stream<T, F, S>(f: F) -> ProcedureStream
where F: Future<Output = Result<S, ProcedureError>> + Send + 'static, S: Stream<Item = Result<T, ProcedureError>> + Send + 'static, T: Serialize + Send + Sync + 'static,

TODO

Source

pub fn from_stream_value<T, S>(s: S) -> ProcedureStream
where S: Stream<Item = Result<T, ProcedureError>> + Send + 'static, T: Send + Sync + 'static,

TODO

Source

pub fn from_future_value<T, F>(f: F) -> ProcedureStream
where F: Future<Output = Result<T, ProcedureError>> + Send + 'static, T: Send + Sync + 'static,

TODO

Source

pub fn from_future_stream_value<T, F, S>(f: F) -> ProcedureStream
where F: Future<Output = Result<S, ProcedureError>> + Send + 'static, S: Stream<Item = Result<T, ProcedureError>> + Send + 'static, T: Send + Sync + 'static,

TODO

Source

pub fn require_manual_stream(self) -> ProcedureStream

By setting this the stream will delay returning any data until instructed by the caller (via Self::stream).

This allows you to progress an entire runtime of streams until all of them are in a state ready to start returning responses. This mechanism allows anything that could need to modify the HTTP response headers to do so before the body starts being streamed.

§Behaviour

ProcedureStream will poll the underlying stream until the first value is ready. It will then return Poll::Pending and go inactive until Self::stream is called. When polled for the first time after Self::stream is called if a value was already ready it will be immediately returned. It is guaranteed that the stream will never yield Poll::Ready until flush is called if this is set.

§Usage

It’s generally expected you will continue to poll the runtime until some criteria based on Self::resolved & Self::flushable is met on all streams. Once this is met you can call Self::stream on all of the streams at once to begin streaming data.

Source

pub fn stream(&mut self)

Start streaming data. Refer to Self::require_manual_stream for more information.

Source

pub fn resolved(&self) -> bool

Will return true if the future has resolved.

For a stream created via Self::from_future* this will be true once the future has resolved and for all other streams this will always be true.

Source

pub fn flushable(&self) -> bool

Will return true if the stream is ready to start streaming data.

This is false until the flush function is called by the user.

Source

pub fn size_hint(&self) -> (usize, Option<usize>)

TODO

Source

pub fn poll_next( &mut self, cx: &mut Context<'_>, ) -> Poll<Option<Result<DynOutput<'_>, ProcedureError>>>

TODO

Source

pub async fn next(&mut self) -> Option<Result<DynOutput<'_>, ProcedureError>>

TODO

Source

pub fn map<F, T>(self, map: F) -> ProcedureStreamMap<F, T>

TODO

Trait Implementations§

Source§

impl Debug for ProcedureStream

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl From<ProcedureError> for ProcedureStream

Source§

fn from(err: ProcedureError) -> ProcedureStream

Converts to this type from the input type.

Auto Trait Implementations§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.