Skip to main content

Output

Struct Output 

Source
pub struct Output<'a> { /* private fields */ }
Expand description

Where an engine writes: the reply body, reused between requests, with a size budget.

Implementations§

Source§

impl<'a> Output<'a>

Source

pub fn new(buf: &'a mut Vec<u8>, limit: usize) -> Self

An output over buf, refusing to grow past limit bytes.

Source

pub fn write(&mut self, bytes: &[u8]) -> Result<(), RenderError>

Appends bytes.

§Errors

render.too_large when the page would pass the budget.

Source

pub fn write_str(&mut self, s: &str) -> Result<(), RenderError>

Appends a string.

§Errors

As write.

Source

pub fn buffer(&mut self) -> &mut Vec<u8> ⓘ

The buffer itself, for an engine that writes into a Vec<u8>. The budget is checked when the engine returns: a page past it is refused with render.too_large.

Source

pub fn len(&self) -> usize

Bytes written so far.

Source

pub fn is_empty(&self) -> bool

Whether nothing was written yet.

Source

pub fn remaining(&self) -> usize

The bytes still allowed.

Trait Implementations§

Source§

impl Debug for Output<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !UnwindSafe for Output<'a>

§

impl<'a> Forget for Output<'a>

§

impl<'a> Freeze for Output<'a>

§

impl<'a> RefUnwindSafe for Output<'a>

§

impl<'a> Send for Output<'a>

§

impl<'a> Sync for Output<'a>

§

impl<'a> Unpin for Output<'a>

§

impl<'a> UnsafeUnpin for Output<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.