pub struct RenderedChunks<V>(/* private fields */);Expand description
Outcome of rendering the individual chunks of a template. This is an intermediate output type that can be resolved into a variety of final output types.
Implementations§
Source§impl<V: RenderValue> RenderedChunks<V>
impl<V: RenderValue> RenderedChunks<V>
Sourcepub fn into_chunks(self) -> Vec<RenderedChunk<V>>
pub fn into_chunks(self) -> Vec<RenderedChunk<V>>
Get the inner list of chunks
Sourcepub fn chunks(&self) -> &[RenderedChunk<V>]
pub fn chunks(&self) -> &[RenderedChunk<V>]
Get the inner chunks as a slice
Sourcepub fn iter(&self) -> impl Iterator<Item = &RenderedChunk<V>>
pub fn iter(&self) -> impl Iterator<Item = &RenderedChunk<V>>
Get an iterator over references to the chunks
Source§impl RenderedChunks<Value>
impl RenderedChunks<Value>
Sourcepub fn try_into_value(self) -> Result<Value, RenderError>
pub fn try_into_value(self) -> Result<Value, RenderError>
Collect the rendered chunks into a Value by these rules:
- If the template is a single dynamic chunk, return the output of that chunk, which may be any type of Value
- Any other template will be rendered to a string by stringifying each dynamic chunk and concatenating them all together
- If rendering to a string fails because the bytes are not valid UTF-8, concatenate into a bytes object instead
Sourcepub fn try_into_bytes(self) -> Result<Bytes, RenderError>
pub fn try_into_bytes(self) -> Result<Bytes, RenderError>
Collect the rendered chunks into a byte string
If any chunk is an error, return an error.
Source§impl RenderedChunks<ValueStream>
impl RenderedChunks<ValueStream>
Sourcepub fn stream_source(&self) -> Option<&StreamSource>
pub fn stream_source(&self) -> Option<&StreamSource>
If this output is a single chunk and that chunk is a stream, get the source of the stream
Sourcepub fn has_stream(&self) -> bool
pub fn has_stream(&self) -> bool
Does this output contain any stream chunks?
Sourcepub async fn try_collect_value(self) -> Result<Value, RenderError>
pub async fn try_collect_value(self) -> Result<Value, RenderError>
Collect the rendered chunks into a Value by these rules:
- If the template is a single dynamic chunk, return the output of that chunk, which may be any type of Value
- If there are any streams, resolve them to bytes
- Any other template will be rendered to a string by stringifying each dynamic chunk and concatenating them all together
- If rendering to a string fails because the bytes are not valid UTF-8, concatenate into a bytes object instead
Sourcepub fn try_into_stream(
self,
) -> Result<impl Stream<Item = Result<Bytes, RenderError>> + Send, RenderError>
pub fn try_into_stream( self, ) -> Result<impl Stream<Item = Result<Bytes, RenderError>> + Send, RenderError>
Convert this output into a byte stream. Each chunk will be yielded as a
separate Bytes output from the stream, except for inner stream chunks,
which can yield any number of values based on their implementation.
Return Err if any of the rendered chunks are errors.
Trait Implementations§
Source§impl<V: Debug> Debug for RenderedChunks<V>
impl<V: Debug> Debug for RenderedChunks<V>
Source§impl<V: From<Value>> From<Result<Value, RenderError>> for RenderedChunks<V>
Create render output of a single chunk that may have failed
impl<V: From<Value>> From<Result<Value, RenderError>> for RenderedChunks<V>
Create render output of a single chunk that may have failed
Source§impl<V: From<Value>> From<Value> for RenderedChunks<V>
Create render output of a single chunk with a value
impl<V: From<Value>> From<Value> for RenderedChunks<V>
Create render output of a single chunk with a value
Source§impl<'a, V> IntoIterator for &'a RenderedChunks<V>
Get an iterator over references to chunks of this output
impl<'a, V> IntoIterator for &'a RenderedChunks<V>
Get an iterator over references to chunks of this output
Source§impl<V> IntoIterator for RenderedChunks<V>
Get an iterator over the chunks of this output
impl<V> IntoIterator for RenderedChunks<V>
Get an iterator over the chunks of this output
Auto Trait Implementations§
impl<V> Freeze for RenderedChunks<V>
impl<V> !RefUnwindSafe for RenderedChunks<V>
impl<V> Send for RenderedChunks<V>where
V: Send,
impl<V> Sync for RenderedChunks<V>where
V: Sync,
impl<V> Unpin for RenderedChunks<V>where
V: Unpin,
impl<V> UnsafeUnpin for RenderedChunks<V>
impl<V> !UnwindSafe for RenderedChunks<V>
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
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>
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>
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