pub struct Response {
pub config: Config,
pub status: Status,
pub headers: JsonValue,
pub cookies: JsonValue,
pub body: Vec<u8>,
pub body_text: JsonValue,
pub request: Request,
}
Expand description
响应
Fields§
§config: Config
§status: Status
§headers: JsonValue
§body: Vec<u8>
消息体
body_text: JsonValue
§request: Request
请求信息
Implementations§
Source§impl Response
impl Response
pub fn default(path: PathBuf) -> Self
pub fn status(&mut self, code: i32) -> &mut Self
Sourcepub fn set_request(&mut self, request: &Request) -> &mut Self
pub fn set_request(&mut self, request: &Request) -> &mut Self
设置 请求内容
pub fn header(&mut self, key: &str, value: &str) -> &mut Self
pub fn update_body(&mut self)
pub fn get_date(&mut self) -> String
Sourcepub fn download(&mut self, filename: &Path) -> &mut Self
pub fn download(&mut self, filename: &Path) -> &mut Self
下载 返回
§Panics
This function will panic if:
filename.extension()
returnsNone
- The extension cannot be converted to a valid UTF-8 string
- The filename cannot be converted to a valid UTF-8 string
Sourcepub fn file(&mut self, filename: &Path) -> &mut Self
pub fn file(&mut self, filename: &Path) -> &mut Self
Serves a file for inline display in the browser.
§Panics
This function will panic if the file extension cannot be converted to a string, or if the filename cannot be converted to a valid UTF-8 string.
pub fn websocket(&mut self, key: &str) -> &mut Self
Trait Implementations§
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