[−][src]Struct funck::Response
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
Auto Trait Implementations
impl RefUnwindSafe for Response
impl Send for Response
impl Sync for Response
impl Unpin for Response
impl UnwindSafe for Response
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,