[][src]Struct funck::Response

pub struct Response { /* fields omitted */ }

Structure for getting data out of a funcktion.

The Response is a way of getting data out of the funcktion. When the funcktion is exposed via HTTP, the response body is sent directly as an HTTP body, and the metadata map is converted to HTTP headers.

Examples

Building a text response

use funck::Response;

let my_response = Response::new().with_text(String::from("Hello, world"));

Building a JSON response.

use funck::Response;

use serde::Serialize;

#[derive(Serialize)]
struct Message {
    pub body: String
}

let a_message = Message{body: String::from("Hello, world")};
let response = Response::new().with_bytes(serde_json::to_vec(&a_message).unwrap());

Methods

impl Response[src]

pub fn new() -> Response[src]

pub fn body(&self) -> &[u8][src]

pub fn with_bytes(self, bytes: Vec<u8>) -> Self[src]

pub fn with_text(self, data: String) -> Self[src]

pub fn writer(&mut self) -> BufWriter<&mut Vec<u8>>[src]

pub fn with_meta(self, key: &str, val: &str) -> Self[src]

pub fn metadata(&self) -> &HashMap<String, String>[src]

Trait Implementations

impl Default for Response[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.