Struct actix_web_lab::respond::Csv
source · [−]pub struct Csv<S> { /* private fields */ }
Expand description
A buffered CSV serializing body stream.
This has significant memory efficiency advantages over returning an array of CSV rows when the data set is very large because it avoids buffering the entire response.
Examples
fn streaming_data_source() -> impl Stream<Item = [String; 2]> {
// get item stream from source
}
async fn handler() -> impl Responder {
let data_stream = streaming_data_source();
Csv::new_infallible(data_stream)
.into_responder()
}
Implementations
sourceimpl<S> Csv<S>
impl<S> Csv<S>
sourcepub fn new_infallible(stream: S) -> Csv<InfallibleStream<S>>
pub fn new_infallible(stream: S) -> Csv<InfallibleStream<S>>
Constructs a new Csv
from an infallible stream of rows.
sourceimpl<S, T, E> Csv<S>where
S: Stream<Item = Result<T, E>>,
T: Serialize,
E: Into<Box<dyn StdError>> + 'static,
impl<S, T, E> Csv<S>where
S: Stream<Item = Result<T, E>>,
T: Serialize,
E: Into<Box<dyn StdError>> + 'static,
sourcepub fn into_body_stream(self) -> impl MessageBody
pub fn into_body_stream(self) -> impl MessageBody
Creates a chunked body stream that serializes as CSV on-the-fly.
sourcepub fn into_responder(self) -> impl Responderwhere
S: 'static,
T: 'static,
E: 'static,
pub fn into_responder(self) -> impl Responderwhere
S: 'static,
T: 'static,
E: 'static,
Creates a Responder
type with a serializing stream and correct Content-Type
header.
sourcepub fn into_chunk_stream(self) -> impl Stream<Item = Result<Bytes, E>>
pub fn into_chunk_stream(self) -> impl Stream<Item = Result<Bytes, E>>
Creates a stream of serialized chunks.
Trait Implementations
Auto Trait Implementations
impl<S> RefUnwindSafe for Csv<S>where
S: RefUnwindSafe,
impl<S> Send for Csv<S>where
S: Send,
impl<S> Sync for Csv<S>where
S: Sync,
impl<S> UnwindSafe for Csv<S>where
S: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for Twhere
V: MultiLane<T>,
impl<V, T> VZip<V> for Twhere
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more