pub struct BatchFrameStream<S> { /* private fields */ }Expand description
Batch frame stream for improved throughput.
Implementations§
Source§impl<S> BatchFrameStream<S>
impl<S> BatchFrameStream<S>
Sourcepub fn new(stream: S, format: StreamFormat, batch_size: usize) -> Self
pub fn new(stream: S, format: StreamFormat, batch_size: usize) -> Self
Wrap a frame stream and emit batches of up to batch_size frames.
Sourcepub fn content_type(&self) -> &'static str
pub fn content_type(&self) -> &'static str
Returns the Content-Type that accurately describes what this stream emits.
BatchFrameStream serializes each batch as newline-delimited JSON objects,
so StreamFormat::Json is promoted to application/x-ndjson — the output
is not a single well-formed JSON document and must not be advertised as one.
Sourcepub fn into_stream(
self,
) -> impl Stream<Item = Result<Vec<u8>, StreamTransportError>> + Send + 'static
pub fn into_stream( self, ) -> impl Stream<Item = Result<Vec<u8>, StreamTransportError>> + Send + 'static
Consume the builder and return a Stream of formatted batch payloads.
Each item is one full batch as Vec<u8>. For StreamFormat::Json and
StreamFormat::NdJson the bytes hold one JSON object per frame, one
per line (NDJSON-of-objects, #167). The stream item type is binary
(Vec<u8>, not String) to leave room for future per-batch
compression (#226).
Auto Trait Implementations§
impl<S> Freeze for BatchFrameStream<S>where
S: Freeze,
impl<S> RefUnwindSafe for BatchFrameStream<S>where
S: RefUnwindSafe,
impl<S> Send for BatchFrameStream<S>where
S: Send,
impl<S> Sync for BatchFrameStream<S>where
S: Sync,
impl<S> Unpin for BatchFrameStream<S>where
S: Unpin,
impl<S> UnsafeUnpin for BatchFrameStream<S>where
S: UnsafeUnpin,
impl<S> UnwindSafe for BatchFrameStream<S>where
S: UnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more