pub struct Response {
pub status_code: u16,
pub status_text: String,
pub headers: Vec<(String, String)>,
pub body: Vec<u8>,
}Fields§
§status_code: u16§status_text: String§headers: Vec<(String, String)>§body: Vec<u8>Implementations§
Source§impl Response
impl Response
pub fn new( status_code: u16, status_text: impl Into<String>, body: impl Into<Vec<u8>>, ) -> Self
pub fn ok(body: impl Into<Vec<u8>>) -> Self
pub fn not_found() -> Self
pub fn bad_request(message: impl Into<Vec<u8>>) -> Self
pub fn internal_server_error() -> Self
pub fn from_error( status_code: u16, status_text: impl Into<String>, body: impl Into<String>, ) -> Self
pub fn with_header( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
pub fn text(body: impl Into<String>) -> Self
pub fn html(body: impl Into<String>) -> Self
pub fn json(body: impl Into<String>) -> Self
pub fn json_value(value: Value) -> Self
pub fn json_serialized<T: Serialize>(value: &T) -> Result<Self, Error>
pub fn to_http_bytes(&self) -> Vec<u8> ⓘ
pub async fn file_async(path: impl AsRef<Path>) -> Self
pub fn file(path: impl AsRef<Path>) -> Self
👎Deprecated:
use Response::file_async instead
Trait Implementations§
Source§impl IntoResponse for Response
impl IntoResponse for Response
fn into_response(self) -> Result<Response, FrameworkError>
Auto Trait Implementations§
impl Freeze for Response
impl RefUnwindSafe for Response
impl Send for Response
impl Sync for Response
impl Unpin for Response
impl UnsafeUnpin 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