[][src]Trait roa::body::PowerBody

pub trait PowerBody {
#[must_use]    fn read<'life0, 'async_trait>(
        &'life0 mut self
    ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
#[must_use] fn read_json<'life0, 'async_trait, B>(
        &'life0 mut self
    ) -> Pin<Box<dyn Future<Output = Result<B>> + Send + 'async_trait>>
    where
        B: DeserializeOwned,
        B: 'async_trait,
        'life0: 'async_trait,
        Self: 'async_trait
;
#[must_use] fn read_form<'life0, 'async_trait, B>(
        &'life0 mut self
    ) -> Pin<Box<dyn Future<Output = Result<B>> + Send + 'async_trait>>
    where
        B: DeserializeOwned,
        B: 'async_trait,
        'life0: 'async_trait,
        Self: 'async_trait
;
fn write_json<B>(&mut self, data: &B) -> Result
    where
        B: Serialize
;
fn render<B>(&mut self, data: &B) -> Result
    where
        B: Template
;
fn write<B>(&mut self, data: B)
    where
        B: Into<Bytes>
;
fn write_reader<B>(&mut self, reader: B)
    where
        B: 'static + AsyncRead + Unpin + Sync + Send
;
#[must_use] fn write_file<'life0, 'async_trait, P>(
        &'life0 mut self,
        path: P,
        typ: DispositionType
    ) -> Pin<Box<dyn Future<Output = Result> + Send + 'async_trait>>
    where
        P: Send + AsRef<Path>,
        P: 'async_trait,
        'life0: 'async_trait,
        Self: 'async_trait
; }

A context extension to read/write body more simply.

Required methods

#[must_use]fn read<'life0, 'async_trait>(
    &'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 

read request body as Bytes.

#[must_use]fn read_json<'life0, 'async_trait, B>(
    &'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<B>> + Send + 'async_trait>> where
    B: DeserializeOwned,
    B: 'async_trait,
    'life0: 'async_trait,
    Self: 'async_trait, 

This is supported on feature="json" only.

read request body as "json".

#[must_use]fn read_form<'life0, 'async_trait, B>(
    &'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<B>> + Send + 'async_trait>> where
    B: DeserializeOwned,
    B: 'async_trait,
    'life0: 'async_trait,
    Self: 'async_trait, 

This is supported on feature="urlencoded" only.

read request body as "urlencoded form".

fn write_json<B>(&mut self, data: &B) -> Result where
    B: Serialize

This is supported on feature="json" only.

write object to response body as "application/json"

fn render<B>(&mut self, data: &B) -> Result where
    B: Template

This is supported on feature="template" only.

write object to response body as "text/html; charset=utf-8"

fn write<B>(&mut self, data: B) where
    B: Into<Bytes>, 

write object to response body as "text/plain"

fn write_reader<B>(&mut self, reader: B) where
    B: 'static + AsyncRead + Unpin + Sync + Send

write object to response body as "application/octet-stream"

#[must_use]fn write_file<'life0, 'async_trait, P>(
    &'life0 mut self,
    path: P,
    typ: DispositionType
) -> Pin<Box<dyn Future<Output = Result> + Send + 'async_trait>> where
    P: Send + AsRef<Path>,
    P: 'async_trait,
    'life0: 'async_trait,
    Self: 'async_trait, 

This is supported on feature="file" only.

write object to response body as extension name of file

Loading content...

Implementors

impl<S: State> PowerBody for Context<S>[src]

Loading content...