@@ -25,6 +25,7 @@ pub struct Response {
25
25
26
26
impl Response {
27
27
/// Create a new instance.
28
+ #[ must_use]
28
29
pub fn new ( status : StatusCode ) -> Self {
29
30
let res = http_types:: Response :: new ( status) ;
30
31
Self {
@@ -72,22 +73,26 @@ impl Response {
72
73
}
73
74
74
75
/// Returns the statuscode.
76
+ #[ must_use]
75
77
pub fn status ( & self ) -> crate :: StatusCode {
76
78
self . res . status ( )
77
79
}
78
80
79
81
/// Set the statuscode.
82
+ #[ must_use]
80
83
pub fn set_status ( mut self , status : crate :: StatusCode ) -> Self {
81
84
self . res . set_status ( status) ;
82
85
self
83
86
}
84
87
85
88
/// Get the length of the body.
89
+ #[ must_use]
86
90
pub fn len ( & self ) -> Option < usize > {
87
91
self . res . len ( )
88
92
}
89
93
90
94
/// Get an HTTP header.
95
+ #[ must_use]
91
96
pub fn header ( & self , name : & HeaderName ) -> Option < & Vec < HeaderValue > > {
92
97
self . res . header ( name)
93
98
}
@@ -126,6 +131,7 @@ impl Response {
126
131
/// Set the request MIME.
127
132
///
128
133
/// [Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types)
134
+ #[ must_use]
129
135
pub fn set_mime ( self , mime : Mime ) -> Self {
130
136
self . set_header ( http_types:: headers:: CONTENT_TYPE , format ! ( "{}" , mime) )
131
137
}
@@ -135,6 +141,7 @@ impl Response {
135
141
/// # Mime
136
142
///
137
143
/// The encoding is set to `text/plain; charset=utf-8`.
144
+ #[ must_use]
138
145
pub fn body_string ( mut self , string : String ) -> Self {
139
146
self . res . set_body ( string) ;
140
147
self . set_mime ( mime:: TEXT_PLAIN_UTF_8 )
@@ -221,6 +228,7 @@ impl Response {
221
228
}
222
229
223
230
/// Get a local value.
231
+ #[ must_use]
224
232
pub fn local < T : Send + Sync + ' static > ( & self ) -> Option < & T > {
225
233
self . res . local ( ) . get ( )
226
234
}
0 commit comments