add Request.method_mut, remove set_*

This commit is contained in:
Sean McArthur
2017-05-31 16:09:11 -07:00
parent e9f464aa7e
commit 7565179a1c

View File

@@ -448,6 +448,7 @@ pub struct Request {
impl Request { impl Request {
/// Constructs a new request. /// Constructs a new request.
#[inline]
pub fn new(method: Method, url: Url) -> Self { pub fn new(method: Method, url: Url) -> Self {
Request { Request {
_version: HttpVersion::Http11, _version: HttpVersion::Http11,
@@ -459,54 +460,52 @@ impl Request {
} }
/// Get the method. /// Get the method.
#[inline]
pub fn method(&self) -> &Method { pub fn method(&self) -> &Method {
&self.method &self.method
} }
/// Set the method. /// Get a mutable reference to the method.
pub fn set_method(&mut self, method: Method) { #[inline]
self.method = method; pub fn method_mut(&mut self) -> &mut Method {
&mut self.method
} }
/// Get the url. /// Get the url.
#[inline]
pub fn url(&self) -> &Url { pub fn url(&self) -> &Url {
&self.url &self.url
} }
/// Get a mutable reference to the url. /// Get a mutable reference to the url.
#[inline]
pub fn url_mut(&mut self) -> &mut Url { pub fn url_mut(&mut self) -> &mut Url {
&mut self.url &mut self.url
} }
/// Set the url.
pub fn set_url(&mut self, url: Url) {
self.url = url;
}
/// Get the headers. /// Get the headers.
#[inline]
pub fn headers(&self) -> &Headers { pub fn headers(&self) -> &Headers {
&self.headers &self.headers
} }
/// Get a mutable reference to the headers. /// Get a mutable reference to the headers.
#[inline]
pub fn headers_mut(&mut self) -> &mut Headers { pub fn headers_mut(&mut self) -> &mut Headers {
&mut self.headers &mut self.headers
} }
/// Get the body. /// Get the body.
#[inline]
pub fn body(&self) -> Option<&Body> { pub fn body(&self) -> Option<&Body> {
self.body.as_ref() self.body.as_ref()
} }
/// Get a mutable reference to the body. /// Get a mutable reference to the body.
#[inline]
pub fn body_mut(&mut self) -> &mut Option<Body> { pub fn body_mut(&mut self) -> &mut Option<Body> {
&mut self.body &mut self.body
} }
/// Set the body.
pub fn set_body(&mut self, body: Option<Body>) {
self.body = body;
}
} }
/// A builder to construct the properties of a `Request`. /// A builder to construct the properties of a `Request`.