pub struct Response {
pub status: u16,
pub headers: Vec<(String, String)>,
pub body: Vec<u8>,
}Expand description
HTTP Get response
Fields§
§status: u16HTTP status code
headers: Vec<(String, String)>HTTP response headers
body: Vec<u8>HTTP response body
Implementations§
Source§impl Response
impl Response
Sourcepub fn extract<E: Extract>(&mut self) -> Result<E, E::Error>
pub fn extract<E: Extract>(&mut self) -> Result<E, E::Error>
Take the payload of the response and decode it.
This consumes the payload; if you call it again, it will return an Error.
use momento_functions_host::encoding::Json;
#[derive(serde::Serialize)]
struct Request {
message: String
}
#[derive(serde::Deserialize)]
struct Reply {
message: String
}
let Json(reply): Json<Reply> = http::post(
"https://gomomento.com",
[
("authorization".to_string(), "abc123".to_string()),
],
Json(Request { message: "hello".to_string() })
)?
.extract()?;Trait Implementations§
Source§impl<'de> Deserialize<'de> for Response
impl<'de> Deserialize<'de> for Response
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Response
impl RefUnwindSafe for Response
impl Send for Response
impl Sync for Response
impl Unpin for Response
impl UnwindSafe for Response
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
Mutably borrows from an owned value. Read more