pub struct ProcedureStream { /* private fields */ }
Expand description
TODO
Implementations§
Source§impl ProcedureStream
impl ProcedureStream
Sourcepub fn from_stream<T, S>(s: S) -> ProcedureStream
pub fn from_stream<T, S>(s: S) -> ProcedureStream
TODO
Sourcepub fn from_future<T, F>(f: F) -> ProcedureStream
pub fn from_future<T, F>(f: F) -> ProcedureStream
TODO
Sourcepub fn from_future_stream<T, F, S>(f: F) -> ProcedureStream
pub fn from_future_stream<T, F, S>(f: F) -> ProcedureStream
TODO
Sourcepub fn from_stream_value<T, S>(s: S) -> ProcedureStream
pub fn from_stream_value<T, S>(s: S) -> ProcedureStream
TODO
Sourcepub fn from_future_value<T, F>(f: F) -> ProcedureStream
pub fn from_future_value<T, F>(f: F) -> ProcedureStream
TODO
Sourcepub fn from_future_stream_value<T, F, S>(f: F) -> ProcedureStreamwhere
F: Future<Output = Result<S, ProcedureError>> + Send + 'static,
S: Stream<Item = Result<T, ProcedureError>> + Send + 'static,
T: Send + Sync + 'static,
pub fn from_future_stream_value<T, F, S>(f: F) -> ProcedureStreamwhere
F: Future<Output = Result<S, ProcedureError>> + Send + 'static,
S: Stream<Item = Result<T, ProcedureError>> + Send + 'static,
T: Send + Sync + 'static,
TODO
Sourcepub fn require_manual_stream(self) -> ProcedureStream
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.
Sourcepub fn stream(&mut self)
pub fn stream(&mut self)
Start streaming data.
Refer to Self::require_manual_stream
for more information.
Sourcepub fn resolved(&self) -> bool
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
.
Sourcepub fn flushable(&self) -> bool
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.
Sourcepub fn poll_next(
&mut self,
cx: &mut Context<'_>,
) -> Poll<Option<Result<DynOutput<'_>, ProcedureError>>>
pub fn poll_next( &mut self, cx: &mut Context<'_>, ) -> Poll<Option<Result<DynOutput<'_>, ProcedureError>>>
TODO
Sourcepub fn map<F, T>(self, map: F) -> ProcedureStreamMap<F, T>
pub fn map<F, T>(self, map: F) -> ProcedureStreamMap<F, T>
TODO