Struct ockam_core::api::Response
source · pub struct Response<T = ()> { /* private fields */ }Implementations§
source§impl<T> Response<T>
impl<T> Response<T>
pub fn id(self, id: Id) -> Self
pub fn status(self, s: Status) -> Self
pub fn header(&self) -> &ResponseHeader
pub fn into_parts(self) -> (ResponseHeader, Option<T>)
sourcepub fn with_headers(self, req: &RequestHeader) -> Self
pub fn with_headers(self, req: &RequestHeader) -> Self
Convenient wrapper to append the requests header to the response
source§impl Response
impl Response
These functions create standard responses
pub fn error(r: &RequestHeader, msg: &str, status: Status) -> Response<Error>
pub fn ok() -> Response
pub fn bad_request_no_request(msg: &str) -> Response<Error>
sourcepub fn bad_request(r: &RequestHeader, msg: &str) -> Response<Error>
pub fn bad_request(r: &RequestHeader, msg: &str) -> Response<Error>
Create a generic bad request response.
pub fn not_found(r: &RequestHeader, msg: &str) -> Response<Error>
pub fn not_found_no_request(msg: &str) -> Response<Error>
pub fn not_implemented(re: Id) -> Response
pub fn forbidden_no_request(re: Id) -> Response
sourcepub fn forbidden(r: &RequestHeader, m: &str) -> Response<Error>
pub fn forbidden(r: &RequestHeader, m: &str) -> Response<Error>
Create an error response with status forbidden and the given message.
pub fn internal_error_no_request(msg: &str) -> Response<Error>
sourcepub fn internal_error(r: &RequestHeader, msg: &str) -> Response<Error>
pub fn internal_error(r: &RequestHeader, msg: &str) -> Response<Error>
Create an internal server error response
sourcepub fn unknown_path(r: &RequestHeader) -> Response<Error>
pub fn unknown_path(r: &RequestHeader) -> Response<Error>
Create an error response because the request path was unknown.
sourcepub fn invalid_method(r: &RequestHeader) -> Response<Error>
pub fn invalid_method(r: &RequestHeader) -> Response<Error>
Create an error response because the request method was unknown or not allowed.
source§impl Response
impl Response
sourcepub fn parse_response_body<T>(bytes: &[u8]) -> Result<T>
pub fn parse_response_body<T>(bytes: &[u8]) -> Result<T>
Parse the response header and if it is ok parse and decode the response body
sourcepub fn parse_response_reply<T>(bytes: &[u8]) -> Result<Reply<T>>
pub fn parse_response_reply<T>(bytes: &[u8]) -> Result<Reply<T>>
Parse the response header and if it is ok parse the response body
sourcepub fn parse_response_header(
bytes: &[u8],
) -> Result<(ResponseHeader, Decoder<'_>)>
pub fn parse_response_header( bytes: &[u8], ) -> Result<(ResponseHeader, Decoder<'_>)>
Parse the response header and return it + the Decoder to continue parsing if necessary
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Response<T>where
T: Freeze,
impl<T> RefUnwindSafe for Response<T>where
T: RefUnwindSafe,
impl<T> Send for Response<T>where
T: Send,
impl<T> Sync for Response<T>where
T: Sync,
impl<T> Unpin for Response<T>where
T: Unpin,
impl<T> UnwindSafe for Response<T>where
T: UnwindSafe,
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