pub struct Streamed(/* private fields */);http and streaming only.Expand description
A JSONL body, written one line at a time.
Built by the generated LIST handler when the client sends
Accept: application/jsonl and the resource routes
STREAM. Each row is serialized, written, and dropped, so
the response holds one row rather than the collection — see
jsonl for the trade this makes against a document.
Implementations§
Source§impl Streamed
impl Streamed
Sourcepub fn new(
lines: impl Stream<Item = Result<Vec<u8>, Infallible>> + Send + Unpin + 'static,
) -> Self
pub fn new( lines: impl Stream<Item = Result<Vec<u8>, Infallible>> + Send + Unpin + 'static, ) -> Self
Build a JSONL body from a stream of already-rendered lines.
Each item is one complete line, newline included. The error type is
Infallible deliberately: a failure has
to become a line rather than a transport error, because the status
was already sent — see ERROR_LINE.
Sourcepub fn line(resource: &ResourceObject) -> Vec<u8> ⓘ
pub fn line(resource: &ResourceObject) -> Vec<u8> ⓘ
Render one resource object as a JSONL line.
Serialization cannot fail for a ResourceObject, but if it somehow
did, an error line is emitted rather than a truncated stream — a
client must never mistake a partial export for a whole one.
Sourcepub fn result_line(resource: &ResourceObject) -> Vec<u8> ⓘ
pub fn result_line(resource: &ResourceObject) -> Vec<u8> ⓘ
Render one created resource as an ingest result line.
A document per line — {"data":{…}} — where line
writes a bare resource object. The difference is deliberate: an
export is a row stream, but an ingest result line sits next to error
lines that are themselves documents, so a client parses every line
the same way and looks for data or errors.
Sourcepub fn error_line_at(error: &JsonApiError, line: usize) -> Vec<u8> ⓘ
pub fn error_line_at(error: &JsonApiError, line: usize) -> Vec<u8> ⓘ
Render an error as one line’s result, stamped with its line number.
The line number is what makes a per-line failure actionable: a client
that sent a hundred thousand rows needs to know which ones did not
land, so it can retry exactly those. See
LINE_MEMBER.
Sourcepub fn error_line(error: &JsonApiError) -> Vec<u8> ⓘ
pub fn error_line(error: &JsonApiError) -> Vec<u8> ⓘ
Render an error as the stream’s final line.
Shaped like a JSON:API error document so a client parsing lines as
JSON finds the same errors member it would in a normal response.