SaResponse

Trait SaResponse 

Source
pub trait SaResponse {
    // Required methods
    fn set_header(&mut self, name: &str, value: &str);
    fn set_cookie(&mut self, name: &str, value: &str, options: CookieOptions);
    fn set_status(&mut self, status: u16);
    fn set_json_body<T>(&mut self, body: T) -> Result<(), Error>
       where T: Serialize;

    // Provided method
    fn delete_cookie(&mut self, name: &str) { ... }
}
Expand description

响应上下文trait

各个Web框架需要为其Response类型实现这个trait

Required Methods§

Source

fn set_header(&mut self, name: &str, value: &str)

设置响应头

设置Cookie

Source

fn set_status(&mut self, status: u16)

设置状态码

Source

fn set_json_body<T>(&mut self, body: T) -> Result<(), Error>
where T: Serialize,

设置响应体(JSON)

Provided Methods§

删除Cookie

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§