Revert adding #[must_use]

This commit is contained in:
Igor Aleksanov 2021-06-25 15:40:53 +03:00
parent 596012086c
commit 759f85e668
45 changed files with 0 additions and 215 deletions

View File

@ -10,7 +10,6 @@
### Changed ### Changed
* Change compression algorithm features flags. [#2250] * Change compression algorithm features flags. [#2250]
* Deprecate `App::data` and `App::data_factory`. [#2271] * Deprecate `App::data` and `App::data_factory`. [#2271]
* Add `#[must_use]` attribute for many public functions/methods. [#2281]
### Fixed ### Fixed
@ -21,7 +20,6 @@
[#2271]: https://github.com/actix/actix-web/pull/2271 [#2271]: https://github.com/actix/actix-web/pull/2271
[#2262]: https://github.com/actix/actix-web/pull/2262 [#2262]: https://github.com/actix/actix-web/pull/2262
[#2263]: https://github.com/actix/actix-web/pull/2263 [#2263]: https://github.com/actix/actix-web/pull/2263
[#2281]: https://github.com/actix/actix-web/pull/2281
[#2288]: https://github.com/actix/actix-web/pull/2288 [#2288]: https://github.com/actix/actix-web/pull/2288

View File

@ -3,14 +3,12 @@
## Unreleased - 2021-xx-xx ## Unreleased - 2021-xx-xx
### Changed ### Changed
* Change compression algorithm features flags. [#2250] * Change compression algorithm features flags. [#2250]
* Add `#[must_use]` attribute for many public functions/methods. [#2281]
### Removed ### Removed
* `downcast` and `downcast_get_type_id` macros. [#2291] * `downcast` and `downcast_get_type_id` macros. [#2291]
[#2291]: https://github.com/actix/actix-web/pull/2291 [#2291]: https://github.com/actix/actix-web/pull/2291
[#2250]: https://github.com/actix/actix-web/pull/2250 [#2250]: https://github.com/actix/actix-web/pull/2250
[#2281]: https://github.com/actix/actix-web/pull/2281
## 3.0.0-beta.7 - 2021-06-17 ## 3.0.0-beta.7 - 2021-06-17

View File

@ -32,7 +32,6 @@ pub enum AnyBody {
impl AnyBody { impl AnyBody {
/// Create body from slice (copy) /// Create body from slice (copy)
#[must_use]
pub fn from_slice(s: &[u8]) -> Self { pub fn from_slice(s: &[u8]) -> Self {
Self::Bytes(Bytes::copy_from_slice(s)) Self::Bytes(Bytes::copy_from_slice(s))
} }

View File

@ -36,7 +36,6 @@ where
<S::Service as Service<Request>>::Future: 'static, <S::Service as Service<Request>>::Future: 'static,
{ {
/// Create instance of `ServiceConfigBuilder` /// Create instance of `ServiceConfigBuilder`
#[must_use]
pub fn new() -> Self { pub fn new() -> Self {
HttpServiceBuilder { HttpServiceBuilder {
keep_alive: KeepAlive::Timeout(5), keep_alive: KeepAlive::Timeout(5),

View File

@ -64,7 +64,6 @@ pub struct Connector<T> {
impl Connector<()> { impl Connector<()> {
#[allow(clippy::new_ret_no_self, clippy::let_unit_value)] #[allow(clippy::new_ret_no_self, clippy::let_unit_value)]
#[must_use]
pub fn new() -> Connector< pub fn new() -> Connector<
impl Service< impl Service<
TcpConnect<Uri>, TcpConnect<Uri>,

View File

@ -68,7 +68,6 @@ impl Default for ServiceConfig {
impl ServiceConfig { impl ServiceConfig {
/// Create instance of `ServiceConfig` /// Create instance of `ServiceConfig`
#[must_use]
pub fn new( pub fn new(
keep_alive: KeepAlive, keep_alive: KeepAlive,
client_timeout: u64, client_timeout: u64,
@ -100,35 +99,30 @@ impl ServiceConfig {
/// Returns true if connection is secure (HTTPS) /// Returns true if connection is secure (HTTPS)
#[inline] #[inline]
#[must_use]
pub fn secure(&self) -> bool { pub fn secure(&self) -> bool {
self.0.secure self.0.secure
} }
/// Returns the local address that this server is bound to. /// Returns the local address that this server is bound to.
#[inline] #[inline]
#[must_use]
pub fn local_addr(&self) -> Option<net::SocketAddr> { pub fn local_addr(&self) -> Option<net::SocketAddr> {
self.0.local_addr self.0.local_addr
} }
/// Keep alive duration if configured. /// Keep alive duration if configured.
#[inline] #[inline]
#[must_use]
pub fn keep_alive(&self) -> Option<Duration> { pub fn keep_alive(&self) -> Option<Duration> {
self.0.keep_alive self.0.keep_alive
} }
/// Return state of connection keep-alive functionality /// Return state of connection keep-alive functionality
#[inline] #[inline]
#[must_use]
pub fn keep_alive_enabled(&self) -> bool { pub fn keep_alive_enabled(&self) -> bool {
self.0.ka_enabled self.0.ka_enabled
} }
/// Client timeout for first request. /// Client timeout for first request.
#[inline] #[inline]
#[must_use]
pub fn client_timer(&self) -> Option<Sleep> { pub fn client_timer(&self) -> Option<Sleep> {
let delay_time = self.0.client_timeout; let delay_time = self.0.client_timeout;
if delay_time != 0 { if delay_time != 0 {
@ -139,7 +133,6 @@ impl ServiceConfig {
} }
/// Client timeout for first request. /// Client timeout for first request.
#[must_use]
pub fn client_timer_expire(&self) -> Option<Instant> { pub fn client_timer_expire(&self) -> Option<Instant> {
let delay = self.0.client_timeout; let delay = self.0.client_timeout;
if delay != 0 { if delay != 0 {
@ -150,7 +143,6 @@ impl ServiceConfig {
} }
/// Client disconnect timer /// Client disconnect timer
#[must_use]
pub fn client_disconnect_timer(&self) -> Option<Instant> { pub fn client_disconnect_timer(&self) -> Option<Instant> {
let delay = self.0.client_disconnect; let delay = self.0.client_disconnect;
if delay != 0 { if delay != 0 {
@ -162,13 +154,11 @@ impl ServiceConfig {
/// Return keep-alive timer delay is configured. /// Return keep-alive timer delay is configured.
#[inline] #[inline]
#[must_use]
pub fn keep_alive_timer(&self) -> Option<Sleep> { pub fn keep_alive_timer(&self) -> Option<Sleep> {
self.keep_alive().map(|ka| sleep_until(self.now() + ka)) self.keep_alive().map(|ka| sleep_until(self.now() + ka))
} }
/// Keep-alive expire time /// Keep-alive expire time
#[must_use]
pub fn keep_alive_expire(&self) -> Option<Instant> { pub fn keep_alive_expire(&self) -> Option<Instant> {
self.keep_alive().map(|ka| self.now() + ka) self.keep_alive().map(|ka| self.now() + ka)
} }

View File

@ -18,7 +18,6 @@ pub struct Extensions {
impl Extensions { impl Extensions {
/// Creates an empty `Extensions`. /// Creates an empty `Extensions`.
#[inline] #[inline]
#[must_use]
pub fn new() -> Extensions { pub fn new() -> Extensions {
Extensions { Extensions {
map: AHashMap::default(), map: AHashMap::default(),
@ -53,7 +52,6 @@ impl Extensions {
/// assert_eq!(map.insert(1u32), None); /// assert_eq!(map.insert(1u32), None);
/// assert!(map.contains::<u32>()); /// assert!(map.contains::<u32>());
/// ``` /// ```
#[must_use]
pub fn contains<T: 'static>(&self) -> bool { pub fn contains<T: 'static>(&self) -> bool {
self.map.contains_key(&TypeId::of::<T>()) self.map.contains_key(&TypeId::of::<T>())
} }
@ -66,7 +64,6 @@ impl Extensions {
/// map.insert(1u32); /// map.insert(1u32);
/// assert_eq!(map.get::<u32>(), Some(&1u32)); /// assert_eq!(map.get::<u32>(), Some(&1u32));
/// ``` /// ```
#[must_use]
pub fn get<T: 'static>(&self) -> Option<&T> { pub fn get<T: 'static>(&self) -> Option<&T> {
self.map self.map
.get(&TypeId::of::<T>()) .get(&TypeId::of::<T>())

View File

@ -53,7 +53,6 @@ impl ClientCodec {
/// Create HTTP/1 codec. /// Create HTTP/1 codec.
/// ///
/// `keepalive_enabled` how response `connection` header get generated. /// `keepalive_enabled` how response `connection` header get generated.
#[must_use]
pub fn new(config: ServiceConfig) -> Self { pub fn new(config: ServiceConfig) -> Self {
let flags = if config.keep_alive_enabled() { let flags = if config.keep_alive_enabled() {
Flags::KEEPALIVE_ENABLED Flags::KEEPALIVE_ENABLED
@ -75,19 +74,16 @@ impl ClientCodec {
} }
/// Check if request is upgrade /// Check if request is upgrade
#[must_use]
pub fn upgrade(&self) -> bool { pub fn upgrade(&self) -> bool {
self.inner.ctype == ConnectionType::Upgrade self.inner.ctype == ConnectionType::Upgrade
} }
/// Check if last response is keep-alive /// Check if last response is keep-alive
#[must_use]
pub fn keepalive(&self) -> bool { pub fn keepalive(&self) -> bool {
self.inner.ctype == ConnectionType::KeepAlive self.inner.ctype == ConnectionType::KeepAlive
} }
/// Check last request's message type /// Check last request's message type
#[must_use]
pub fn message_type(&self) -> MessageType { pub fn message_type(&self) -> MessageType {
if self.inner.flags.contains(Flags::STREAM) { if self.inner.flags.contains(Flags::STREAM) {
MessageType::Stream MessageType::Stream
@ -99,7 +95,6 @@ impl ClientCodec {
} }
/// Convert message codec to a payload codec /// Convert message codec to a payload codec
#[must_use]
pub fn into_payload_codec(self) -> ClientPayloadCodec { pub fn into_payload_codec(self) -> ClientPayloadCodec {
ClientPayloadCodec { inner: self.inner } ClientPayloadCodec { inner: self.inner }
} }
@ -107,13 +102,11 @@ impl ClientCodec {
impl ClientPayloadCodec { impl ClientPayloadCodec {
/// Check if last response is keep-alive /// Check if last response is keep-alive
#[must_use]
pub fn keepalive(&self) -> bool { pub fn keepalive(&self) -> bool {
self.inner.ctype == ConnectionType::KeepAlive self.inner.ctype == ConnectionType::KeepAlive
} }
/// Transform payload codec to a message codec /// Transform payload codec to a message codec
#[must_use]
pub fn into_message_codec(self) -> ClientCodec { pub fn into_message_codec(self) -> ClientCodec {
ClientCodec { inner: self.inner } ClientCodec { inner: self.inner }
} }

View File

@ -52,7 +52,6 @@ impl Codec {
/// Create HTTP/1 codec. /// Create HTTP/1 codec.
/// ///
/// `keepalive_enabled` how response `connection` header get generated. /// `keepalive_enabled` how response `connection` header get generated.
#[must_use]
pub fn new(config: ServiceConfig) -> Self { pub fn new(config: ServiceConfig) -> Self {
let flags = if config.keep_alive_enabled() { let flags = if config.keep_alive_enabled() {
Flags::KEEPALIVE_ENABLED Flags::KEEPALIVE_ENABLED
@ -73,28 +72,24 @@ impl Codec {
/// Check if request is upgrade. /// Check if request is upgrade.
#[inline] #[inline]
#[must_use]
pub fn upgrade(&self) -> bool { pub fn upgrade(&self) -> bool {
self.ctype == ConnectionType::Upgrade self.ctype == ConnectionType::Upgrade
} }
/// Check if last response is keep-alive. /// Check if last response is keep-alive.
#[inline] #[inline]
#[must_use]
pub fn keepalive(&self) -> bool { pub fn keepalive(&self) -> bool {
self.ctype == ConnectionType::KeepAlive self.ctype == ConnectionType::KeepAlive
} }
/// Check if keep-alive enabled on server level. /// Check if keep-alive enabled on server level.
#[inline] #[inline]
#[must_use]
pub fn keepalive_enabled(&self) -> bool { pub fn keepalive_enabled(&self) -> bool {
self.flags.contains(Flags::KEEPALIVE_ENABLED) self.flags.contains(Flags::KEEPALIVE_ENABLED)
} }
/// Check last request's message type. /// Check last request's message type.
#[inline] #[inline]
#[must_use]
pub fn message_type(&self) -> MessageType { pub fn message_type(&self) -> MessageType {
if self.flags.contains(Flags::STREAM) { if self.flags.contains(Flags::STREAM) {
MessageType::Stream MessageType::Stream
@ -106,7 +101,6 @@ impl Codec {
} }
#[inline] #[inline]
#[must_use]
pub fn config(&self) -> &ServiceConfig { pub fn config(&self) -> &ServiceConfig {
&self.config &self.config
} }

View File

@ -41,7 +41,6 @@ impl Payload {
/// * `PayloadSender` - *Sender* side of the stream /// * `PayloadSender` - *Sender* side of the stream
/// ///
/// * `Payload` - *Receiver* side of the stream /// * `Payload` - *Receiver* side of the stream
#[must_use]
pub fn create(eof: bool) -> (PayloadSender, Payload) { pub fn create(eof: bool) -> (PayloadSender, Payload) {
let shared = Rc::new(RefCell::new(Inner::new(eof))); let shared = Rc::new(RefCell::new(Inner::new(eof)));
@ -55,7 +54,6 @@ impl Payload {
/// Create empty payload /// Create empty payload
#[doc(hidden)] #[doc(hidden)]
#[must_use]
pub fn empty() -> Payload { pub fn empty() -> Payload {
Payload { Payload {
inner: Rc::new(RefCell::new(Inner::new(true))), inner: Rc::new(RefCell::new(Inner::new(true))),

View File

@ -81,7 +81,6 @@ impl HeaderMap {
/// assert!(map.is_empty()); /// assert!(map.is_empty());
/// assert_eq!(0, map.capacity()); /// assert_eq!(0, map.capacity());
/// ``` /// ```
#[must_use]
pub fn new() -> Self { pub fn new() -> Self {
HeaderMap::default() HeaderMap::default()
} }
@ -99,7 +98,6 @@ impl HeaderMap {
/// assert!(map.is_empty()); /// assert!(map.is_empty());
/// assert!(map.capacity() >= 16); /// assert!(map.capacity() >= 16);
/// ``` /// ```
#[must_use]
pub fn with_capacity(capacity: usize) -> Self { pub fn with_capacity(capacity: usize) -> Self {
HeaderMap { HeaderMap {
inner: AHashMap::with_capacity(capacity), inner: AHashMap::with_capacity(capacity),
@ -152,7 +150,6 @@ impl HeaderMap {
/// map.append(header::SET_COOKIE, HeaderValue::from_static("two=2")); /// map.append(header::SET_COOKIE, HeaderValue::from_static("two=2"));
/// assert_eq!(map.len(), 3); /// assert_eq!(map.len(), 3);
/// ``` /// ```
#[must_use]
pub fn len(&self) -> usize { pub fn len(&self) -> usize {
self.inner self.inner
.iter() .iter()
@ -176,7 +173,6 @@ impl HeaderMap {
/// map.append(header::SET_COOKIE, HeaderValue::from_static("two=2")); /// map.append(header::SET_COOKIE, HeaderValue::from_static("two=2"));
/// assert_eq!(map.len_keys(), 2); /// assert_eq!(map.len_keys(), 2);
/// ``` /// ```
#[must_use]
pub fn len_keys(&self) -> usize { pub fn len_keys(&self) -> usize {
self.inner.len() self.inner.len()
} }
@ -192,7 +188,6 @@ impl HeaderMap {
/// map.insert(header::ACCEPT, HeaderValue::from_static("text/plain")); /// map.insert(header::ACCEPT, HeaderValue::from_static("text/plain"));
/// assert!(!map.is_empty()); /// assert!(!map.is_empty());
/// ``` /// ```
#[must_use]
pub fn is_empty(&self) -> bool { pub fn is_empty(&self) -> bool {
self.inner.len() == 0 self.inner.len() == 0
} }
@ -439,7 +434,6 @@ impl HeaderMap {
/// assert!(map.is_empty()); /// assert!(map.is_empty());
/// assert!(map.capacity() >= 16); /// assert!(map.capacity() >= 16);
/// ``` /// ```
#[must_use]
pub fn capacity(&self) -> usize { pub fn capacity(&self) -> usize {
self.inner.capacity() self.inner.capacity()
} }
@ -495,7 +489,6 @@ impl HeaderMap {
/// assert!(pairs.contains(&(&header::SET_COOKIE, &HeaderValue::from_static("one=1")))); /// assert!(pairs.contains(&(&header::SET_COOKIE, &HeaderValue::from_static("one=1"))));
/// assert!(pairs.contains(&(&header::SET_COOKIE, &HeaderValue::from_static("two=2")))); /// assert!(pairs.contains(&(&header::SET_COOKIE, &HeaderValue::from_static("two=2"))));
/// ``` /// ```
#[must_use]
pub fn iter(&self) -> Iter<'_> { pub fn iter(&self) -> Iter<'_> {
Iter::new(self.inner.iter()) Iter::new(self.inner.iter())
} }
@ -522,7 +515,6 @@ impl HeaderMap {
/// assert!(keys.contains(&header::HOST)); /// assert!(keys.contains(&header::HOST));
/// assert!(keys.contains(&header::SET_COOKIE)); /// assert!(keys.contains(&header::SET_COOKIE));
/// ``` /// ```
#[must_use]
pub fn keys(&self) -> Keys<'_> { pub fn keys(&self) -> Keys<'_> {
Keys(self.inner.keys()) Keys(self.inner.keys())
} }

View File

@ -33,14 +33,12 @@ pub enum ContentEncoding {
impl ContentEncoding { impl ContentEncoding {
/// Is the content compressed? /// Is the content compressed?
#[inline] #[inline]
#[must_use]
pub fn is_compression(self) -> bool { pub fn is_compression(self) -> bool {
matches!(self, ContentEncoding::Identity | ContentEncoding::Auto) matches!(self, ContentEncoding::Identity | ContentEncoding::Auto)
} }
/// Convert content encoding to string /// Convert content encoding to string
#[inline] #[inline]
#[must_use]
pub fn as_str(self) -> &'static str { pub fn as_str(self) -> &'static str {
match self { match self {
ContentEncoding::Br => "br", ContentEncoding::Br => "br",
@ -53,7 +51,6 @@ impl ContentEncoding {
/// Default Q-factor (quality) value. /// Default Q-factor (quality) value.
#[inline] #[inline]
#[must_use]
pub fn quality(self) -> f64 { pub fn quality(self) -> f64 {
match self { match self {
ContentEncoding::Br => 1.1, ContentEncoding::Br => 1.1,

View File

@ -234,7 +234,6 @@ pub struct ResponseHead {
impl ResponseHead { impl ResponseHead {
/// Create new instance of `ResponseHead` type /// Create new instance of `ResponseHead` type
#[inline] #[inline]
#[must_use]
pub fn new(status: StatusCode) -> ResponseHead { pub fn new(status: StatusCode) -> ResponseHead {
ResponseHead { ResponseHead {
status, status,
@ -355,7 +354,6 @@ pub struct Message<T: Head> {
impl<T: Head> Message<T> { impl<T: Head> Message<T> {
/// Get new message from the pool of objects /// Get new message from the pool of objects
#[must_use]
pub fn new() -> Self { pub fn new() -> Self {
T::with_pool(MessagePool::get_message) T::with_pool(MessagePool::get_message)
} }

View File

@ -57,7 +57,6 @@ impl From<Message<RequestHead>> for Request<PayloadStream> {
impl Request<PayloadStream> { impl Request<PayloadStream> {
/// Create new Request instance /// Create new Request instance
#[must_use]
pub fn new() -> Request<PayloadStream> { pub fn new() -> Request<PayloadStream> {
Request { Request {
head: Message::new(), head: Message::new(),

View File

@ -25,7 +25,6 @@ pub struct Response<B> {
impl Response<AnyBody> { impl Response<AnyBody> {
/// Constructs a new response with default body. /// Constructs a new response with default body.
#[inline] #[inline]
#[must_use]
pub fn new(status: StatusCode) -> Self { pub fn new(status: StatusCode) -> Self {
Response { Response {
head: BoxedResponseHead::new(status), head: BoxedResponseHead::new(status),
@ -35,7 +34,6 @@ impl Response<AnyBody> {
/// Constructs a new response builder. /// Constructs a new response builder.
#[inline] #[inline]
#[must_use]
pub fn build(status: StatusCode) -> ResponseBuilder { pub fn build(status: StatusCode) -> ResponseBuilder {
ResponseBuilder::new(status) ResponseBuilder::new(status)
} }
@ -45,28 +43,24 @@ impl Response<AnyBody> {
/// Constructs a new response with status 200 OK. /// Constructs a new response with status 200 OK.
#[inline] #[inline]
#[must_use]
pub fn ok() -> Self { pub fn ok() -> Self {
Response::new(StatusCode::OK) Response::new(StatusCode::OK)
} }
/// Constructs a new response with status 400 Bad Request. /// Constructs a new response with status 400 Bad Request.
#[inline] #[inline]
#[must_use]
pub fn bad_request() -> Self { pub fn bad_request() -> Self {
Response::new(StatusCode::BAD_REQUEST) Response::new(StatusCode::BAD_REQUEST)
} }
/// Constructs a new response with status 404 Not Found. /// Constructs a new response with status 404 Not Found.
#[inline] #[inline]
#[must_use]
pub fn not_found() -> Self { pub fn not_found() -> Self {
Response::new(StatusCode::NOT_FOUND) Response::new(StatusCode::NOT_FOUND)
} }
/// Constructs a new response with status 500 Internal Server Error. /// Constructs a new response with status 500 Internal Server Error.
#[inline] #[inline]
#[must_use]
pub fn internal_server_error() -> Self { pub fn internal_server_error() -> Self {
Response::new(StatusCode::INTERNAL_SERVER_ERROR) Response::new(StatusCode::INTERNAL_SERVER_ERROR)
} }

View File

@ -62,7 +62,6 @@ impl ResponseBuilder {
/// assert_eq!(res.status(), StatusCode::OK); /// assert_eq!(res.status(), StatusCode::OK);
/// ``` /// ```
#[inline] #[inline]
#[must_use]
pub fn new(status: StatusCode) -> Self { pub fn new(status: StatusCode) -> Self {
ResponseBuilder { ResponseBuilder {
head: Some(BoxedResponseHead::new(status)), head: Some(BoxedResponseHead::new(status)),
@ -221,7 +220,6 @@ impl ResponseBuilder {
/// Responses extensions /// Responses extensions
#[inline] #[inline]
#[must_use]
pub fn extensions(&self) -> Ref<'_, Extensions> { pub fn extensions(&self) -> Ref<'_, Extensions> {
let head = self.head.as_ref().expect("cannot reuse response builder"); let head = self.head.as_ref().expect("cannot reuse response builder");
head.extensions.borrow() head.extensions.borrow()

View File

@ -47,7 +47,6 @@ where
B: MessageBody + 'static, B: MessageBody + 'static,
{ {
/// Create builder for `HttpService` instance. /// Create builder for `HttpService` instance.
#[must_use]
pub fn build() -> HttpServiceBuilder<T, S> { pub fn build() -> HttpServiceBuilder<T, S> {
HttpServiceBuilder::new() HttpServiceBuilder::new()
} }

View File

@ -80,7 +80,6 @@ bitflags! {
impl Codec { impl Codec {
/// Create new WebSocket frames decoder. /// Create new WebSocket frames decoder.
#[must_use]
pub const fn new() -> Codec { pub const fn new() -> Codec {
Codec { Codec {
max_size: 65_536, max_size: 65_536,
@ -91,7 +90,6 @@ impl Codec {
/// Set max frame size. /// Set max frame size.
/// ///
/// By default max size is set to 64kB. /// By default max size is set to 64kB.
#[must_use]
pub fn max_size(mut self, size: usize) -> Self { pub fn max_size(mut self, size: usize) -> Self {
self.max_size = size; self.max_size = size;
self self
@ -100,7 +98,6 @@ impl Codec {
/// Set decoder to client mode. /// Set decoder to client mode.
/// ///
/// By default decoder works in server mode. /// By default decoder works in server mode.
#[must_use]
pub fn client_mode(mut self) -> Self { pub fn client_mode(mut self) -> Self {
self.flags.remove(Flags::SERVER); self.flags.remove(Flags::SERVER);
self self

View File

@ -139,7 +139,6 @@ impl Parser {
} }
/// Parse the payload of a close frame. /// Parse the payload of a close frame.
#[must_use]
pub fn parse_close_payload(payload: &[u8]) -> Option<CloseReason> { pub fn parse_close_payload(payload: &[u8]) -> Option<CloseReason> {
if payload.len() >= 2 { if payload.len() >= 2 {
let raw_code = u16::from_be_bytes(TryFrom::try_from(&payload[..2]).unwrap()); let raw_code = u16::from_be_bytes(TryFrom::try_from(&payload[..2]).unwrap());

View File

@ -226,7 +226,6 @@ static WS_GUID: &[u8] = b"258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
/// Hashes the `Sec-WebSocket-Key` header according to the WebSocket spec. /// Hashes the `Sec-WebSocket-Key` header according to the WebSocket spec.
/// ///
/// Result is a Base64 encoded byte array. `base64(sha1(input))` is always 28 bytes. /// Result is a Base64 encoded byte array. `base64(sha1(input))` is always 28 bytes.
#[must_use]
pub fn hash_key(key: &[u8]) -> [u8; 28] { pub fn hash_key(key: &[u8]) -> [u8; 28] {
let hash = { let hash = {
use sha1::Digest as _; use sha1::Digest as _;

View File

@ -42,7 +42,6 @@ pub struct App<T, B> {
impl App<AppEntry, Body> { impl App<AppEntry, Body> {
/// Create application builder. Application can be configured with a builder-like pattern. /// Create application builder. Application can be configured with a builder-like pattern.
#[allow(clippy::new_without_default)] #[allow(clippy::new_without_default)]
#[must_use]
pub fn new() -> Self { pub fn new() -> Self {
let factory_ref = Rc::new(RefCell::new(None)); let factory_ref = Rc::new(RefCell::new(None));

View File

@ -44,7 +44,6 @@ impl AppService {
} }
/// Check if root is being configured /// Check if root is being configured
#[must_use]
pub fn is_root(&self) -> bool { pub fn is_root(&self) -> bool {
self.root self.root
} }
@ -75,13 +74,11 @@ impl AppService {
} }
/// Returns reference to configuration. /// Returns reference to configuration.
#[must_use]
pub fn config(&self) -> &AppConfig { pub fn config(&self) -> &AppConfig {
&self.config &self.config
} }
/// Returns default handler factory. /// Returns default handler factory.
#[must_use]
pub fn default_service(&self) -> Rc<HttpNewService> { pub fn default_service(&self) -> Rc<HttpNewService> {
self.default.clone() self.default.clone()
} }
@ -134,19 +131,16 @@ impl AppConfig {
/// documentation for more information. /// documentation for more information.
/// ///
/// By default host name is set to a "localhost" value. /// By default host name is set to a "localhost" value.
#[must_use]
pub fn host(&self) -> &str { pub fn host(&self) -> &str {
&self.host &self.host
} }
/// Returns true if connection is secure(https) /// Returns true if connection is secure(https)
#[must_use]
pub fn secure(&self) -> bool { pub fn secure(&self) -> bool {
self.secure self.secure
} }
/// Returns the socket address of the local half of this TCP connection /// Returns the socket address of the local half of this TCP connection
#[must_use]
pub fn local_addr(&self) -> SocketAddr { pub fn local_addr(&self) -> SocketAddr {
self.addr self.addr
} }

View File

@ -77,13 +77,11 @@ impl<T> Data<T> {
} }
/// Get reference to inner app data. /// Get reference to inner app data.
#[must_use]
pub fn get_ref(&self) -> &T { pub fn get_ref(&self) -> &T {
self.0.as_ref() self.0.as_ref()
} }
/// Convert to the internal Arc<T> /// Convert to the internal Arc<T>
#[must_use]
pub fn into_inner(self) -> Arc<T> { pub fn into_inner(self) -> Arc<T> {
self.0 self.0
} }

View File

@ -20,19 +20,16 @@ pub struct Error {
impl Error { impl Error {
/// Returns the reference to the underlying `ResponseError`. /// Returns the reference to the underlying `ResponseError`.
#[must_use]
pub fn as_response_error(&self) -> &dyn ResponseError { pub fn as_response_error(&self) -> &dyn ResponseError {
self.cause.as_ref() self.cause.as_ref()
} }
/// Similar to `as_response_error` but downcasts. /// Similar to `as_response_error` but downcasts.
#[must_use]
pub fn as_error<T: ResponseError + 'static>(&self) -> Option<&T> { pub fn as_error<T: ResponseError + 'static>(&self) -> Option<&T> {
<dyn ResponseError>::downcast_ref(self.cause.as_ref()) <dyn ResponseError>::downcast_ref(self.cause.as_ref())
} }
/// Shortcut for creating an `HttpResponse`. /// Shortcut for creating an `HttpResponse`.
#[must_use]
pub fn error_response(&self) -> HttpResponse { pub fn error_response(&self) -> HttpResponse {
self.cause.error_response() self.cause.error_response()
} }

View File

@ -195,68 +195,57 @@ impl Guard for MethodGuard {
} }
/// Guard to match *GET* HTTP method. /// Guard to match *GET* HTTP method.
#[must_use]
pub fn Get() -> MethodGuard { pub fn Get() -> MethodGuard {
MethodGuard(http::Method::GET) MethodGuard(http::Method::GET)
} }
/// Predicate to match *POST* HTTP method. /// Predicate to match *POST* HTTP method.
#[must_use]
pub fn Post() -> MethodGuard { pub fn Post() -> MethodGuard {
MethodGuard(http::Method::POST) MethodGuard(http::Method::POST)
} }
/// Predicate to match *PUT* HTTP method. /// Predicate to match *PUT* HTTP method.
#[must_use]
pub fn Put() -> MethodGuard { pub fn Put() -> MethodGuard {
MethodGuard(http::Method::PUT) MethodGuard(http::Method::PUT)
} }
/// Predicate to match *DELETE* HTTP method. /// Predicate to match *DELETE* HTTP method.
#[must_use]
pub fn Delete() -> MethodGuard { pub fn Delete() -> MethodGuard {
MethodGuard(http::Method::DELETE) MethodGuard(http::Method::DELETE)
} }
/// Predicate to match *HEAD* HTTP method. /// Predicate to match *HEAD* HTTP method.
#[must_use]
pub fn Head() -> MethodGuard { pub fn Head() -> MethodGuard {
MethodGuard(http::Method::HEAD) MethodGuard(http::Method::HEAD)
} }
/// Predicate to match *OPTIONS* HTTP method. /// Predicate to match *OPTIONS* HTTP method.
#[must_use]
pub fn Options() -> MethodGuard { pub fn Options() -> MethodGuard {
MethodGuard(http::Method::OPTIONS) MethodGuard(http::Method::OPTIONS)
} }
/// Predicate to match *CONNECT* HTTP method. /// Predicate to match *CONNECT* HTTP method.
#[must_use]
pub fn Connect() -> MethodGuard { pub fn Connect() -> MethodGuard {
MethodGuard(http::Method::CONNECT) MethodGuard(http::Method::CONNECT)
} }
/// Predicate to match *PATCH* HTTP method. /// Predicate to match *PATCH* HTTP method.
#[must_use]
pub fn Patch() -> MethodGuard { pub fn Patch() -> MethodGuard {
MethodGuard(http::Method::PATCH) MethodGuard(http::Method::PATCH)
} }
/// Predicate to match *TRACE* HTTP method. /// Predicate to match *TRACE* HTTP method.
#[must_use]
pub fn Trace() -> MethodGuard { pub fn Trace() -> MethodGuard {
MethodGuard(http::Method::TRACE) MethodGuard(http::Method::TRACE)
} }
/// Predicate to match specified HTTP method. /// Predicate to match specified HTTP method.
#[must_use]
pub fn Method(method: http::Method) -> MethodGuard { pub fn Method(method: http::Method) -> MethodGuard {
MethodGuard(method) MethodGuard(method)
} }
/// Return predicate that matches if request contains specified header and /// Return predicate that matches if request contains specified header and
/// value. /// value.
#[must_use]
pub fn Header(name: &'static str, value: &'static str) -> HeaderGuard { pub fn Header(name: &'static str, value: &'static str) -> HeaderGuard {
HeaderGuard( HeaderGuard(
header::HeaderName::try_from(name).unwrap(), header::HeaderName::try_from(name).unwrap(),

View File

@ -126,31 +126,26 @@ crate::http::header::common_header! {
impl Accept { impl Accept {
/// Construct `Accept: */*`. /// Construct `Accept: */*`.
#[must_use]
pub fn star() -> Accept { pub fn star() -> Accept {
Accept(vec![qitem(mime::STAR_STAR)]) Accept(vec![qitem(mime::STAR_STAR)])
} }
/// Construct `Accept: application/json`. /// Construct `Accept: application/json`.
#[must_use]
pub fn json() -> Accept { pub fn json() -> Accept {
Accept(vec![qitem(mime::APPLICATION_JSON)]) Accept(vec![qitem(mime::APPLICATION_JSON)])
} }
/// Construct `Accept: text/*`. /// Construct `Accept: text/*`.
#[must_use]
pub fn text() -> Accept { pub fn text() -> Accept {
Accept(vec![qitem(mime::TEXT_STAR)]) Accept(vec![qitem(mime::TEXT_STAR)])
} }
/// Construct `Accept: image/*`. /// Construct `Accept: image/*`.
#[must_use]
pub fn image() -> Accept { pub fn image() -> Accept {
Accept(vec![qitem(mime::IMAGE_STAR)]) Accept(vec![qitem(mime::IMAGE_STAR)])
} }
/// Construct `Accept: text/html`. /// Construct `Accept: text/html`.
#[must_use]
pub fn html() -> Accept { pub fn html() -> Accept {
Accept(vec![qitem(mime::TEXT_HTML)]) Accept(vec![qitem(mime::TEXT_HTML)])
} }
@ -159,7 +154,6 @@ impl Accept {
/// [q-factor weighting] and specificity. /// [q-factor weighting] and specificity.
/// ///
/// [q-factor weighting]: https://tools.ietf.org/html/rfc7231#section-5.3.2 /// [q-factor weighting]: https://tools.ietf.org/html/rfc7231#section-5.3.2
#[must_use]
pub fn mime_precedence(&self) -> Vec<Mime> { pub fn mime_precedence(&self) -> Vec<Mime> {
let mut types = self.0.clone(); let mut types = self.0.clone();
@ -210,7 +204,6 @@ impl Accept {
/// Returns `None` if contained list is empty. /// Returns `None` if contained list is empty.
/// ///
/// [q-factor weighting]: https://tools.ietf.org/html/rfc7231#section-5.3.2 /// [q-factor weighting]: https://tools.ietf.org/html/rfc7231#section-5.3.2
#[must_use]
pub fn mime_preference(&self) -> Option<Mime> { pub fn mime_preference(&self) -> Option<Mime> {
let types = self.mime_precedence(); let types = self.mime_precedence();
types.first().cloned() types.first().cloned()

View File

@ -101,28 +101,24 @@ pub enum DispositionParam {
impl DispositionParam { impl DispositionParam {
/// Returns `true` if the parameter is [`Name`](DispositionParam::Name). /// Returns `true` if the parameter is [`Name`](DispositionParam::Name).
#[inline] #[inline]
#[must_use]
pub fn is_name(&self) -> bool { pub fn is_name(&self) -> bool {
self.as_name().is_some() self.as_name().is_some()
} }
/// Returns `true` if the parameter is [`Filename`](DispositionParam::Filename). /// Returns `true` if the parameter is [`Filename`](DispositionParam::Filename).
#[inline] #[inline]
#[must_use]
pub fn is_filename(&self) -> bool { pub fn is_filename(&self) -> bool {
self.as_filename().is_some() self.as_filename().is_some()
} }
/// Returns `true` if the parameter is [`FilenameExt`](DispositionParam::FilenameExt). /// Returns `true` if the parameter is [`FilenameExt`](DispositionParam::FilenameExt).
#[inline] #[inline]
#[must_use]
pub fn is_filename_ext(&self) -> bool { pub fn is_filename_ext(&self) -> bool {
self.as_filename_ext().is_some() self.as_filename_ext().is_some()
} }
/// Returns `true` if the parameter is [`Unknown`](DispositionParam::Unknown) and the `name` /// Returns `true` if the parameter is [`Unknown`](DispositionParam::Unknown) and the `name`
#[inline] #[inline]
#[must_use]
/// matches. /// matches.
pub fn is_unknown<T: AsRef<str>>(&self, name: T) -> bool { pub fn is_unknown<T: AsRef<str>>(&self, name: T) -> bool {
self.as_unknown(name).is_some() self.as_unknown(name).is_some()
@ -131,14 +127,12 @@ impl DispositionParam {
/// Returns `true` if the parameter is [`UnknownExt`](DispositionParam::UnknownExt) and the /// Returns `true` if the parameter is [`UnknownExt`](DispositionParam::UnknownExt) and the
/// `name` matches. /// `name` matches.
#[inline] #[inline]
#[must_use]
pub fn is_unknown_ext<T: AsRef<str>>(&self, name: T) -> bool { pub fn is_unknown_ext<T: AsRef<str>>(&self, name: T) -> bool {
self.as_unknown_ext(name).is_some() self.as_unknown_ext(name).is_some()
} }
/// Returns the name if applicable. /// Returns the name if applicable.
#[inline] #[inline]
#[must_use]
pub fn as_name(&self) -> Option<&str> { pub fn as_name(&self) -> Option<&str> {
match self { match self {
DispositionParam::Name(ref name) => Some(name.as_str()), DispositionParam::Name(ref name) => Some(name.as_str()),
@ -148,7 +142,6 @@ impl DispositionParam {
/// Returns the filename if applicable. /// Returns the filename if applicable.
#[inline] #[inline]
#[must_use]
pub fn as_filename(&self) -> Option<&str> { pub fn as_filename(&self) -> Option<&str> {
match self { match self {
DispositionParam::Filename(ref filename) => Some(filename.as_str()), DispositionParam::Filename(ref filename) => Some(filename.as_str()),
@ -158,7 +151,6 @@ impl DispositionParam {
/// Returns the filename* if applicable. /// Returns the filename* if applicable.
#[inline] #[inline]
#[must_use]
pub fn as_filename_ext(&self) -> Option<&ExtendedValue> { pub fn as_filename_ext(&self) -> Option<&ExtendedValue> {
match self { match self {
DispositionParam::FilenameExt(ref value) => Some(value), DispositionParam::FilenameExt(ref value) => Some(value),
@ -169,7 +161,6 @@ impl DispositionParam {
/// Returns the value of the unrecognized regular parameter if it is /// Returns the value of the unrecognized regular parameter if it is
/// [`Unknown`](DispositionParam::Unknown) and the `name` matches. /// [`Unknown`](DispositionParam::Unknown) and the `name` matches.
#[inline] #[inline]
#[must_use]
pub fn as_unknown<T: AsRef<str>>(&self, name: T) -> Option<&str> { pub fn as_unknown<T: AsRef<str>>(&self, name: T) -> Option<&str> {
match self { match self {
DispositionParam::Unknown(ref ext_name, ref value) DispositionParam::Unknown(ref ext_name, ref value)
@ -184,7 +175,6 @@ impl DispositionParam {
/// Returns the value of the unrecognized extended parameter if it is /// Returns the value of the unrecognized extended parameter if it is
/// [`Unknown`](DispositionParam::Unknown) and the `name` matches. /// [`Unknown`](DispositionParam::Unknown) and the `name` matches.
#[inline] #[inline]
#[must_use]
pub fn as_unknown_ext<T: AsRef<str>>(&self, name: T) -> Option<&ExtendedValue> { pub fn as_unknown_ext<T: AsRef<str>>(&self, name: T) -> Option<&ExtendedValue> {
match self { match self {
DispositionParam::UnknownExt(ref ext_name, ref value) DispositionParam::UnknownExt(ref ext_name, ref value)
@ -396,25 +386,21 @@ impl ContentDisposition {
} }
/// Returns `true` if it is [`Inline`](DispositionType::Inline). /// Returns `true` if it is [`Inline`](DispositionType::Inline).
#[must_use]
pub fn is_inline(&self) -> bool { pub fn is_inline(&self) -> bool {
matches!(self.disposition, DispositionType::Inline) matches!(self.disposition, DispositionType::Inline)
} }
/// Returns `true` if it is [`Attachment`](DispositionType::Attachment). /// Returns `true` if it is [`Attachment`](DispositionType::Attachment).
#[must_use]
pub fn is_attachment(&self) -> bool { pub fn is_attachment(&self) -> bool {
matches!(self.disposition, DispositionType::Attachment) matches!(self.disposition, DispositionType::Attachment)
} }
/// Returns `true` if it is [`FormData`](DispositionType::FormData). /// Returns `true` if it is [`FormData`](DispositionType::FormData).
#[must_use]
pub fn is_form_data(&self) -> bool { pub fn is_form_data(&self) -> bool {
matches!(self.disposition, DispositionType::FormData) matches!(self.disposition, DispositionType::FormData)
} }
/// Returns `true` if it is [`Ext`](DispositionType::Ext) and the `disp_type` matches. /// Returns `true` if it is [`Ext`](DispositionType::Ext) and the `disp_type` matches.
#[must_use]
pub fn is_ext(&self, disp_type: impl AsRef<str>) -> bool { pub fn is_ext(&self, disp_type: impl AsRef<str>) -> bool {
matches!( matches!(
self.disposition, self.disposition,
@ -423,13 +409,11 @@ impl ContentDisposition {
} }
/// Return the value of *name* if exists. /// Return the value of *name* if exists.
#[must_use]
pub fn get_name(&self) -> Option<&str> { pub fn get_name(&self) -> Option<&str> {
self.parameters.iter().find_map(DispositionParam::as_name) self.parameters.iter().find_map(DispositionParam::as_name)
} }
/// Return the value of *filename* if exists. /// Return the value of *filename* if exists.
#[must_use]
pub fn get_filename(&self) -> Option<&str> { pub fn get_filename(&self) -> Option<&str> {
self.parameters self.parameters
.iter() .iter()
@ -437,7 +421,6 @@ impl ContentDisposition {
} }
/// Return the value of *filename\** if exists. /// Return the value of *filename\** if exists.
#[must_use]
pub fn get_filename_ext(&self) -> Option<&ExtendedValue> { pub fn get_filename_ext(&self) -> Option<&ExtendedValue> {
self.parameters self.parameters
.iter() .iter()
@ -445,14 +428,12 @@ impl ContentDisposition {
} }
/// Return the value of the parameter which the `name` matches. /// Return the value of the parameter which the `name` matches.
#[must_use]
pub fn get_unknown(&self, name: impl AsRef<str>) -> Option<&str> { pub fn get_unknown(&self, name: impl AsRef<str>) -> Option<&str> {
let name = name.as_ref(); let name = name.as_ref();
self.parameters.iter().find_map(|p| p.as_unknown(name)) self.parameters.iter().find_map(|p| p.as_unknown(name))
} }
/// Return the value of the extended parameter which the `name` matches. /// Return the value of the extended parameter which the `name` matches.
#[must_use]
pub fn get_unknown_ext(&self, name: impl AsRef<str>) -> Option<&ExtendedValue> { pub fn get_unknown_ext(&self, name: impl AsRef<str>) -> Option<&ExtendedValue> {
let name = name.as_ref(); let name = name.as_ref();
self.parameters.iter().find_map(|p| p.as_unknown_ext(name)) self.parameters.iter().find_map(|p| p.as_unknown_ext(name))

View File

@ -63,7 +63,6 @@ impl ContentType {
/// A constructor to easily create a `Content-Type: application/json` /// A constructor to easily create a `Content-Type: application/json`
/// header. /// header.
#[inline] #[inline]
#[must_use]
pub fn json() -> ContentType { pub fn json() -> ContentType {
ContentType(mime::APPLICATION_JSON) ContentType(mime::APPLICATION_JSON)
} }
@ -71,21 +70,18 @@ impl ContentType {
/// A constructor to easily create a `Content-Type: text/plain; /// A constructor to easily create a `Content-Type: text/plain;
/// charset=utf-8` header. /// charset=utf-8` header.
#[inline] #[inline]
#[must_use]
pub fn plaintext() -> ContentType { pub fn plaintext() -> ContentType {
ContentType(mime::TEXT_PLAIN_UTF_8) ContentType(mime::TEXT_PLAIN_UTF_8)
} }
/// A constructor to easily create a `Content-Type: text/html` header. /// A constructor to easily create a `Content-Type: text/html` header.
#[inline] #[inline]
#[must_use]
pub fn html() -> ContentType { pub fn html() -> ContentType {
ContentType(mime::TEXT_HTML) ContentType(mime::TEXT_HTML)
} }
/// A constructor to easily create a `Content-Type: text/xml` header. /// A constructor to easily create a `Content-Type: text/xml` header.
#[inline] #[inline]
#[must_use]
pub fn xml() -> ContentType { pub fn xml() -> ContentType {
ContentType(mime::TEXT_XML) ContentType(mime::TEXT_XML)
} }
@ -93,21 +89,18 @@ impl ContentType {
/// A constructor to easily create a `Content-Type: /// A constructor to easily create a `Content-Type:
/// application/www-form-url-encoded` header. /// application/www-form-url-encoded` header.
#[inline] #[inline]
#[must_use]
pub fn form_url_encoded() -> ContentType { pub fn form_url_encoded() -> ContentType {
ContentType(mime::APPLICATION_WWW_FORM_URLENCODED) ContentType(mime::APPLICATION_WWW_FORM_URLENCODED)
} }
/// A constructor to easily create a `Content-Type: image/jpeg` header. /// A constructor to easily create a `Content-Type: image/jpeg` header.
#[inline] #[inline]
#[must_use]
pub fn jpeg() -> ContentType { pub fn jpeg() -> ContentType {
ContentType(mime::IMAGE_JPEG) ContentType(mime::IMAGE_JPEG)
} }
/// A constructor to easily create a `Content-Type: image/png` header. /// A constructor to easily create a `Content-Type: image/png` header.
#[inline] #[inline]
#[must_use]
pub fn png() -> ContentType { pub fn png() -> ContentType {
ContentType(mime::IMAGE_PNG) ContentType(mime::IMAGE_PNG)
} }
@ -115,7 +108,6 @@ impl ContentType {
/// A constructor to easily create a `Content-Type: /// A constructor to easily create a `Content-Type:
/// application/octet-stream` header. /// application/octet-stream` header.
#[inline] #[inline]
#[must_use]
pub fn octet_stream() -> ContentType { pub fn octet_stream() -> ContentType {
ContentType(mime::APPLICATION_OCTET_STREAM) ContentType(mime::APPLICATION_OCTET_STREAM)
} }

View File

@ -38,7 +38,6 @@ crate::http::header::common_header! {
impl Date { impl Date {
/// Create a date instance set to the current system time /// Create a date instance set to the current system time
#[must_use]
pub fn now() -> Date { pub fn now() -> Date {
Date(SystemTime::now().into()) Date(SystemTime::now().into())
} }

View File

@ -58,7 +58,6 @@ impl EntityTag {
/// Constructs a new EntityTag. /// Constructs a new EntityTag.
/// # Panics /// # Panics
/// If the tag contains invalid characters. /// If the tag contains invalid characters.
#[must_use]
pub fn new(weak: bool, tag: String) -> EntityTag { pub fn new(weak: bool, tag: String) -> EntityTag {
assert!(check_slice_validity(&tag), "Invalid tag: {:?}", tag); assert!(check_slice_validity(&tag), "Invalid tag: {:?}", tag);
EntityTag { weak, tag } EntityTag { weak, tag }
@ -67,7 +66,6 @@ impl EntityTag {
/// Constructs a new weak EntityTag. /// Constructs a new weak EntityTag.
/// # Panics /// # Panics
/// If the tag contains invalid characters. /// If the tag contains invalid characters.
#[must_use]
pub fn weak(tag: String) -> EntityTag { pub fn weak(tag: String) -> EntityTag {
EntityTag::new(true, tag) EntityTag::new(true, tag)
} }
@ -75,13 +73,11 @@ impl EntityTag {
/// Constructs a new strong EntityTag. /// Constructs a new strong EntityTag.
/// # Panics /// # Panics
/// If the tag contains invalid characters. /// If the tag contains invalid characters.
#[must_use]
pub fn strong(tag: String) -> EntityTag { pub fn strong(tag: String) -> EntityTag {
EntityTag::new(false, tag) EntityTag::new(false, tag)
} }
/// Get the tag. /// Get the tag.
#[must_use]
pub fn tag(&self) -> &str { pub fn tag(&self) -> &str {
self.tag.as_ref() self.tag.as_ref()
} }
@ -96,7 +92,6 @@ impl EntityTag {
/// For strong comparison two entity-tags are equivalent if both are not /// For strong comparison two entity-tags are equivalent if both are not
/// weak and their opaque-tags match character-by-character. /// weak and their opaque-tags match character-by-character.
#[must_use]
pub fn strong_eq(&self, other: &EntityTag) -> bool { pub fn strong_eq(&self, other: &EntityTag) -> bool {
!self.weak && !other.weak && self.tag == other.tag !self.weak && !other.weak && self.tag == other.tag
} }
@ -104,19 +99,16 @@ impl EntityTag {
/// For weak comparison two entity-tags are equivalent if their /// For weak comparison two entity-tags are equivalent if their
/// opaque-tags match character-by-character, regardless of either or /// opaque-tags match character-by-character, regardless of either or
/// both being tagged as "weak". /// both being tagged as "weak".
#[must_use]
pub fn weak_eq(&self, other: &EntityTag) -> bool { pub fn weak_eq(&self, other: &EntityTag) -> bool {
self.tag == other.tag self.tag == other.tag
} }
/// The inverse of `EntityTag.strong_eq()`. /// The inverse of `EntityTag.strong_eq()`.
#[must_use]
pub fn strong_ne(&self, other: &EntityTag) -> bool { pub fn strong_ne(&self, other: &EntityTag) -> bool {
!self.strong_eq(other) !self.strong_eq(other)
} }
/// The inverse of `EntityTag.weak_eq()`. /// The inverse of `EntityTag.weak_eq()`.
#[must_use]
pub fn weak_ne(&self, other: &EntityTag) -> bool { pub fn weak_ne(&self, other: &EntityTag) -> bool {
!self.weak_eq(other) !self.weak_eq(other)
} }

View File

@ -161,7 +161,6 @@ impl ConnectionInfo {
/// - X-Forwarded-Proto /// - X-Forwarded-Proto
/// - Uri /// - Uri
#[inline] #[inline]
#[must_use]
pub fn scheme(&self) -> &str { pub fn scheme(&self) -> &str {
&self.scheme &self.scheme
} }
@ -175,7 +174,6 @@ impl ConnectionInfo {
/// - Host /// - Host
/// - Uri /// - Uri
/// - Server hostname /// - Server hostname
#[must_use]
pub fn host(&self) -> &str { pub fn host(&self) -> &str {
&self.host &self.host
} }
@ -183,7 +181,6 @@ impl ConnectionInfo {
/// remote_addr address of the request. /// remote_addr address of the request.
/// ///
/// Get remote_addr address from socket address /// Get remote_addr address from socket address
#[must_use]
pub fn remote_addr(&self) -> Option<&str> { pub fn remote_addr(&self) -> Option<&str> {
self.remote_addr.as_ref().map(String::as_ref) self.remote_addr.as_ref().map(String::as_ref)
} }
@ -201,7 +198,6 @@ impl ConnectionInfo {
/// address explicitly, use /// address explicitly, use
/// [`HttpRequest::peer_addr()`](super::web::HttpRequest::peer_addr()) instead. /// [`HttpRequest::peer_addr()`](super::web::HttpRequest::peer_addr()) instead.
#[inline] #[inline]
#[must_use]
pub fn realip_remote_addr(&self) -> Option<&str> { pub fn realip_remote_addr(&self) -> Option<&str> {
if let Some(ref r) = self.realip_remote_addr { if let Some(ref r) = self.realip_remote_addr {
Some(r) Some(r)

View File

@ -43,7 +43,6 @@ pub struct Compress(ContentEncoding);
impl Compress { impl Compress {
/// Create new `Compress` middleware with the specified encoding. /// Create new `Compress` middleware with the specified encoding.
#[must_use]
pub fn new(encoding: ContentEncoding) -> Self { pub fn new(encoding: ContentEncoding) -> Self {
Compress(encoding) Compress(encoding)
} }

View File

@ -65,7 +65,6 @@ impl HttpRequest {
impl HttpRequest { impl HttpRequest {
/// This method returns reference to the request head /// This method returns reference to the request head
#[inline] #[inline]
#[must_use]
pub fn head(&self) -> &RequestHead { pub fn head(&self) -> &RequestHead {
&self.inner.head &self.inner.head
} }
@ -79,27 +78,23 @@ impl HttpRequest {
/// Request's uri. /// Request's uri.
#[inline] #[inline]
#[must_use]
pub fn uri(&self) -> &Uri { pub fn uri(&self) -> &Uri {
&self.head().uri &self.head().uri
} }
/// Read the Request method. /// Read the Request method.
#[inline] #[inline]
#[must_use]
pub fn method(&self) -> &Method { pub fn method(&self) -> &Method {
&self.head().method &self.head().method
} }
/// Read the Request Version. /// Read the Request Version.
#[inline] #[inline]
#[must_use]
pub fn version(&self) -> Version { pub fn version(&self) -> Version {
self.head().version self.head().version
} }
#[inline] #[inline]
#[must_use]
/// Returns request's headers. /// Returns request's headers.
pub fn headers(&self) -> &HeaderMap { pub fn headers(&self) -> &HeaderMap {
&self.head().headers &self.head().headers
@ -107,7 +102,6 @@ impl HttpRequest {
/// The target path of this Request. /// The target path of this Request.
#[inline] #[inline]
#[must_use]
pub fn path(&self) -> &str { pub fn path(&self) -> &str {
self.head().uri.path() self.head().uri.path()
} }
@ -116,7 +110,6 @@ impl HttpRequest {
/// ///
/// E.g., id=10 /// E.g., id=10
#[inline] #[inline]
#[must_use]
pub fn query_string(&self) -> &str { pub fn query_string(&self) -> &str {
self.uri().query().unwrap_or_default() self.uri().query().unwrap_or_default()
} }
@ -128,7 +121,6 @@ impl HttpRequest {
/// where the identifier can be used later in a request handler to /// where the identifier can be used later in a request handler to
/// access the matched value for that segment. /// access the matched value for that segment.
#[inline] #[inline]
#[must_use]
pub fn match_info(&self) -> &Path<Url> { pub fn match_info(&self) -> &Path<Url> {
&self.inner.path &self.inner.path
} }
@ -145,7 +137,6 @@ impl HttpRequest {
/// ///
/// Returns a None when no resource is fully matched, including default services. /// Returns a None when no resource is fully matched, including default services.
#[inline] #[inline]
#[must_use]
pub fn match_pattern(&self) -> Option<String> { pub fn match_pattern(&self) -> Option<String> {
self.resource_map().match_pattern(self.path()) self.resource_map().match_pattern(self.path())
} }
@ -154,21 +145,18 @@ impl HttpRequest {
/// ///
/// Returns a None when no resource is fully matched, including default services. /// Returns a None when no resource is fully matched, including default services.
#[inline] #[inline]
#[must_use]
pub fn match_name(&self) -> Option<&str> { pub fn match_name(&self) -> Option<&str> {
self.resource_map().match_name(self.path()) self.resource_map().match_name(self.path())
} }
/// Request extensions /// Request extensions
#[inline] #[inline]
#[must_use]
pub fn extensions(&self) -> Ref<'_, Extensions> { pub fn extensions(&self) -> Ref<'_, Extensions> {
self.head().extensions() self.head().extensions()
} }
/// Mutable reference to a the request's extensions /// Mutable reference to a the request's extensions
#[inline] #[inline]
#[must_use]
pub fn extensions_mut(&self) -> RefMut<'_, Extensions> { pub fn extensions_mut(&self) -> RefMut<'_, Extensions> {
self.head().extensions_mut() self.head().extensions_mut()
} }
@ -209,7 +197,6 @@ impl HttpRequest {
} }
#[inline] #[inline]
#[must_use]
/// Get a reference to a `ResourceMap` of current application. /// Get a reference to a `ResourceMap` of current application.
pub fn resource_map(&self) -> &ResourceMap { pub fn resource_map(&self) -> &ResourceMap {
&self.app_state().rmap() &self.app_state().rmap()
@ -224,7 +211,6 @@ impl HttpRequest {
/// ///
/// Will only return None when called in unit tests. /// Will only return None when called in unit tests.
#[inline] #[inline]
#[must_use]
pub fn peer_addr(&self) -> Option<net::SocketAddr> { pub fn peer_addr(&self) -> Option<net::SocketAddr> {
self.head().peer_addr self.head().peer_addr
} }
@ -234,14 +220,12 @@ impl HttpRequest {
/// This method panics if request's extensions container is already /// This method panics if request's extensions container is already
/// borrowed. /// borrowed.
#[inline] #[inline]
#[must_use]
pub fn connection_info(&self) -> Ref<'_, ConnectionInfo> { pub fn connection_info(&self) -> Ref<'_, ConnectionInfo> {
ConnectionInfo::get(self.head(), self.app_config()) ConnectionInfo::get(self.head(), self.app_config())
} }
/// App config /// App config
#[inline] #[inline]
#[must_use]
pub fn app_config(&self) -> &AppConfig { pub fn app_config(&self) -> &AppConfig {
self.app_state().config() self.app_state().config()
} }
@ -254,7 +238,6 @@ impl HttpRequest {
/// ```ignore /// ```ignore
/// let opt_t = req.app_data::<Data<T>>(); /// let opt_t = req.app_data::<Data<T>>();
/// ``` /// ```
#[must_use]
pub fn app_data<T: 'static>(&self) -> Option<&T> { pub fn app_data<T: 'static>(&self) -> Option<&T> {
for container in self.inner.app_data.iter().rev() { for container in self.inner.app_data.iter().rev() {
if let Some(data) = container.get::<T>() { if let Some(data) = container.get::<T>() {
@ -295,7 +278,6 @@ impl HttpRequest {
/// Return request cookie. /// Return request cookie.
#[cfg(feature = "cookies")] #[cfg(feature = "cookies")]
#[must_use]
pub fn cookie(&self, name: &str) -> Option<Cookie<'static>> { pub fn cookie(&self, name: &str) -> Option<Cookie<'static>> {
if let Ok(cookies) = self.cookies() { if let Ok(cookies) = self.cookies() {
for cookie in cookies.iter() { for cookie in cookies.iter() {

View File

@ -42,7 +42,6 @@ pub struct HttpResponseBuilder {
impl HttpResponseBuilder { impl HttpResponseBuilder {
#[inline] #[inline]
/// Create response builder /// Create response builder
#[must_use]
pub fn new(status: StatusCode) -> Self { pub fn new(status: StatusCode) -> Self {
Self { Self {
res: Some(Response::new(status)), res: Some(Response::new(status)),

View File

@ -7,7 +7,6 @@ use crate::{HttpResponse, HttpResponseBuilder};
macro_rules! static_resp { macro_rules! static_resp {
($name:ident, $status:expr) => { ($name:ident, $status:expr) => {
#[allow(non_snake_case, missing_docs)] #[allow(non_snake_case, missing_docs)]
#[must_use]
pub fn $name() -> HttpResponseBuilder { pub fn $name() -> HttpResponseBuilder {
HttpResponseBuilder::new($status) HttpResponseBuilder::new($status)
} }

View File

@ -33,13 +33,11 @@ pub struct HttpResponse<B = AnyBody> {
impl HttpResponse<AnyBody> { impl HttpResponse<AnyBody> {
/// Create HTTP response builder with specific status. /// Create HTTP response builder with specific status.
#[inline] #[inline]
#[must_use]
pub fn build(status: StatusCode) -> HttpResponseBuilder { pub fn build(status: StatusCode) -> HttpResponseBuilder {
HttpResponseBuilder::new(status) HttpResponseBuilder::new(status)
} }
/// Create a response. /// Create a response.
#[must_use]
#[inline] #[inline]
pub fn new(status: StatusCode) -> Self { pub fn new(status: StatusCode) -> Self {
Self { Self {
@ -50,7 +48,6 @@ impl HttpResponse<AnyBody> {
/// Create an error response. /// Create an error response.
#[inline] #[inline]
#[must_use]
pub fn from_error(error: impl Into<Error>) -> Self { pub fn from_error(error: impl Into<Error>) -> Self {
let error = error.into(); let error = error.into();
let mut response = error.as_response_error().error_response(); let mut response = error.as_response_error().error_response();

View File

@ -17,7 +17,6 @@ pub struct ResourceMap {
} }
impl ResourceMap { impl ResourceMap {
#[must_use]
pub fn new(root: ResourceDef) -> Self { pub fn new(root: ResourceDef) -> Self {
ResourceMap { ResourceMap {
root, root,

View File

@ -28,7 +28,6 @@ pub struct Route {
impl Route { impl Route {
/// Create new route which matches any request. /// Create new route which matches any request.
#[allow(clippy::new_without_default)] #[allow(clippy::new_without_default)]
#[must_use]
pub fn new() -> Route { pub fn new() -> Route {
Route { Route {
service: boxed::factory(HandlerService::new(HttpResponse::NotFound)), service: boxed::factory(HandlerService::new(HttpResponse::NotFound)),
@ -102,7 +101,6 @@ impl Route {
/// ); /// );
/// # } /// # }
/// ``` /// ```
#[must_use]
pub fn method(mut self, method: Method) -> Self { pub fn method(mut self, method: Method) -> Self {
Rc::get_mut(&mut self.guards) Rc::get_mut(&mut self.guards)
.unwrap() .unwrap()

View File

@ -65,7 +65,6 @@ pub struct Scope<T = ScopeEndpoint> {
impl Scope { impl Scope {
/// Create a new scope /// Create a new scope
#[must_use]
pub fn new(path: &str) -> Scope { pub fn new(path: &str) -> Scope {
let factory_ref = Rc::new(RefCell::new(None)); let factory_ref = Rc::new(RefCell::new(None));

View File

@ -75,7 +75,6 @@ impl ServiceRequest {
/// Deconstruct request into parts /// Deconstruct request into parts
#[inline] #[inline]
#[must_use]
pub fn into_parts(self) -> (HttpRequest, Payload) { pub fn into_parts(self) -> (HttpRequest, Payload) {
(self.req, self.payload) (self.req, self.payload)
} }
@ -87,7 +86,6 @@ impl ServiceRequest {
} }
/// Construct request from parts. /// Construct request from parts.
#[must_use]
pub fn from_parts(req: HttpRequest, payload: Payload) -> Self { pub fn from_parts(req: HttpRequest, payload: Payload) -> Self {
Self { req, payload } Self { req, payload }
} }
@ -95,7 +93,6 @@ impl ServiceRequest {
/// Construct request from request. /// Construct request from request.
/// ///
/// The returned `ServiceRequest` would have no payload. /// The returned `ServiceRequest` would have no payload.
#[must_use]
pub fn from_request(req: HttpRequest) -> Self { pub fn from_request(req: HttpRequest) -> Self {
ServiceRequest { ServiceRequest {
req, req,
@ -119,7 +116,6 @@ impl ServiceRequest {
/// This method returns reference to the request head /// This method returns reference to the request head
#[inline] #[inline]
#[must_use]
pub fn head(&self) -> &RequestHead { pub fn head(&self) -> &RequestHead {
&self.req.head() &self.req.head()
} }
@ -132,34 +128,29 @@ impl ServiceRequest {
/// Request's uri. /// Request's uri.
#[inline] #[inline]
#[must_use]
pub fn uri(&self) -> &Uri { pub fn uri(&self) -> &Uri {
&self.head().uri &self.head().uri
} }
/// Read the Request method. /// Read the Request method.
#[inline] #[inline]
#[must_use]
pub fn method(&self) -> &Method { pub fn method(&self) -> &Method {
&self.head().method &self.head().method
} }
/// Read the Request Version. /// Read the Request Version.
#[inline] #[inline]
#[must_use]
pub fn version(&self) -> Version { pub fn version(&self) -> Version {
self.head().version self.head().version
} }
#[inline] #[inline]
#[must_use]
/// Returns request's headers. /// Returns request's headers.
pub fn headers(&self) -> &HeaderMap { pub fn headers(&self) -> &HeaderMap {
&self.head().headers &self.head().headers
} }
#[inline] #[inline]
#[must_use]
/// Returns mutable request's headers. /// Returns mutable request's headers.
pub fn headers_mut(&mut self) -> &mut HeaderMap { pub fn headers_mut(&mut self) -> &mut HeaderMap {
&mut self.head_mut().headers &mut self.head_mut().headers
@ -167,7 +158,6 @@ impl ServiceRequest {
/// The target path of this Request. /// The target path of this Request.
#[inline] #[inline]
#[must_use]
pub fn path(&self) -> &str { pub fn path(&self) -> &str {
self.head().uri.path() self.head().uri.path()
} }
@ -176,7 +166,6 @@ impl ServiceRequest {
/// ///
/// E.g., id=10 /// E.g., id=10
#[inline] #[inline]
#[must_use]
pub fn query_string(&self) -> &str { pub fn query_string(&self) -> &str {
self.uri().query().unwrap_or_default() self.uri().query().unwrap_or_default()
} }
@ -190,14 +179,12 @@ impl ServiceRequest {
/// ///
/// Will only return None when called in unit tests. /// Will only return None when called in unit tests.
#[inline] #[inline]
#[must_use]
pub fn peer_addr(&self) -> Option<net::SocketAddr> { pub fn peer_addr(&self) -> Option<net::SocketAddr> {
self.head().peer_addr self.head().peer_addr
} }
/// Get *ConnectionInfo* for the current request. /// Get *ConnectionInfo* for the current request.
#[inline] #[inline]
#[must_use]
pub fn connection_info(&self) -> Ref<'_, ConnectionInfo> { pub fn connection_info(&self) -> Ref<'_, ConnectionInfo> {
ConnectionInfo::get(self.head(), &*self.app_config()) ConnectionInfo::get(self.head(), &*self.app_config())
} }
@ -209,34 +196,29 @@ impl ServiceRequest {
/// where the identifier can be used later in a request handler to /// where the identifier can be used later in a request handler to
/// access the matched value for that segment. /// access the matched value for that segment.
#[inline] #[inline]
#[must_use]
pub fn match_info(&self) -> &Path<Url> { pub fn match_info(&self) -> &Path<Url> {
self.req.match_info() self.req.match_info()
} }
/// Counterpart to [`HttpRequest::match_name`](super::HttpRequest::match_name()). /// Counterpart to [`HttpRequest::match_name`](super::HttpRequest::match_name()).
#[inline] #[inline]
#[must_use]
pub fn match_name(&self) -> Option<&str> { pub fn match_name(&self) -> Option<&str> {
self.req.match_name() self.req.match_name()
} }
/// Counterpart to [`HttpRequest::match_pattern`](super::HttpRequest::match_pattern()). /// Counterpart to [`HttpRequest::match_pattern`](super::HttpRequest::match_pattern()).
#[inline] #[inline]
#[must_use]
pub fn match_pattern(&self) -> Option<String> { pub fn match_pattern(&self) -> Option<String> {
self.req.match_pattern() self.req.match_pattern()
} }
#[inline] #[inline]
#[must_use]
/// Get a mutable reference to the Path parameters. /// Get a mutable reference to the Path parameters.
pub fn match_info_mut(&mut self) -> &mut Path<Url> { pub fn match_info_mut(&mut self) -> &mut Path<Url> {
self.req.match_info_mut() self.req.match_info_mut()
} }
#[inline] #[inline]
#[must_use]
/// Get a reference to a `ResourceMap` of current application. /// Get a reference to a `ResourceMap` of current application.
pub fn resource_map(&self) -> &ResourceMap { pub fn resource_map(&self) -> &ResourceMap {
self.req.resource_map() self.req.resource_map()
@ -244,13 +226,11 @@ impl ServiceRequest {
/// Service configuration /// Service configuration
#[inline] #[inline]
#[must_use]
pub fn app_config(&self) -> &AppConfig { pub fn app_config(&self) -> &AppConfig {
self.req.app_config() self.req.app_config()
} }
/// Counterpart to [`HttpRequest::app_data`](super::HttpRequest::app_data()). /// Counterpart to [`HttpRequest::app_data`](super::HttpRequest::app_data()).
#[must_use]
pub fn app_data<T: 'static>(&self) -> Option<&T> { pub fn app_data<T: 'static>(&self) -> Option<&T> {
for container in self.req.inner.app_data.iter().rev() { for container in self.req.inner.app_data.iter().rev() {
if let Some(data) = container.get::<T>() { if let Some(data) = container.get::<T>() {
@ -268,7 +248,6 @@ impl ServiceRequest {
/// Return request cookie. /// Return request cookie.
#[cfg(feature = "cookies")] #[cfg(feature = "cookies")]
#[must_use]
pub fn cookie(&self, name: &str) -> Option<Cookie<'static>> { pub fn cookie(&self, name: &str) -> Option<Cookie<'static>> {
self.req.cookie(name) self.req.cookie(name)
} }
@ -497,7 +476,6 @@ impl WebService {
/// Set service name. /// Set service name.
/// ///
/// Name is used for url generation. /// Name is used for url generation.
#[must_use]
pub fn name(mut self, name: &str) -> Self { pub fn name(mut self, name: &str) -> Self {
self.name = Some(name.to_string()); self.name = Some(name.to_string());
self self

View File

@ -31,14 +31,12 @@ use crate::{
}; };
/// Create service that always responds with `HttpResponse::Ok()` and no body. /// Create service that always responds with `HttpResponse::Ok()` and no body.
#[must_use]
pub fn ok_service( pub fn ok_service(
) -> impl Service<ServiceRequest, Response = ServiceResponse<Body>, Error = Error> { ) -> impl Service<ServiceRequest, Response = ServiceResponse<Body>, Error = Error> {
default_service(StatusCode::OK) default_service(StatusCode::OK)
} }
/// Create service that always responds with given status code and no body. /// Create service that always responds with given status code and no body.
#[must_use]
pub fn default_service( pub fn default_service(
status_code: StatusCode, status_code: StatusCode,
) -> impl Service<ServiceRequest, Response = ServiceResponse<Body>, Error = Error> { ) -> impl Service<ServiceRequest, Response = ServiceResponse<Body>, Error = Error> {
@ -400,37 +398,31 @@ impl Default for TestRequest {
#[allow(clippy::wrong_self_convention)] #[allow(clippy::wrong_self_convention)]
impl TestRequest { impl TestRequest {
/// Create TestRequest and set request uri /// Create TestRequest and set request uri
#[must_use]
pub fn with_uri(path: &str) -> TestRequest { pub fn with_uri(path: &str) -> TestRequest {
TestRequest::default().uri(path) TestRequest::default().uri(path)
} }
/// Create TestRequest and set method to `Method::GET` /// Create TestRequest and set method to `Method::GET`
#[must_use]
pub fn get() -> TestRequest { pub fn get() -> TestRequest {
TestRequest::default().method(Method::GET) TestRequest::default().method(Method::GET)
} }
/// Create TestRequest and set method to `Method::POST` /// Create TestRequest and set method to `Method::POST`
#[must_use]
pub fn post() -> TestRequest { pub fn post() -> TestRequest {
TestRequest::default().method(Method::POST) TestRequest::default().method(Method::POST)
} }
/// Create TestRequest and set method to `Method::PUT` /// Create TestRequest and set method to `Method::PUT`
#[must_use]
pub fn put() -> TestRequest { pub fn put() -> TestRequest {
TestRequest::default().method(Method::PUT) TestRequest::default().method(Method::PUT)
} }
/// Create TestRequest and set method to `Method::PATCH` /// Create TestRequest and set method to `Method::PATCH`
#[must_use]
pub fn patch() -> TestRequest { pub fn patch() -> TestRequest {
TestRequest::default().method(Method::PATCH) TestRequest::default().method(Method::PATCH)
} }
/// Create TestRequest and set method to `Method::DELETE` /// Create TestRequest and set method to `Method::DELETE`
#[must_use]
pub fn delete() -> TestRequest { pub fn delete() -> TestRequest {
TestRequest::default().method(Method::DELETE) TestRequest::default().method(Method::DELETE)
} }

View File

@ -228,14 +228,12 @@ pub struct FormConfig {
impl FormConfig { impl FormConfig {
/// Set maximum accepted payload size. By default this limit is 16kB. /// Set maximum accepted payload size. By default this limit is 16kB.
#[must_use]
pub fn limit(mut self, limit: usize) -> Self { pub fn limit(mut self, limit: usize) -> Self {
self.limit = limit; self.limit = limit;
self self
} }
/// Set custom error handler /// Set custom error handler
#[must_use]
pub fn error_handler<F>(mut self, f: F) -> Self pub fn error_handler<F>(mut self, f: F) -> Self
where where
F: Fn(UrlencodedError, &HttpRequest) -> Error + 'static, F: Fn(UrlencodedError, &HttpRequest) -> Error + 'static,
@ -332,7 +330,6 @@ impl<T> UrlEncoded<T> {
} }
/// Set maximum accepted payload size. The default limit is 256kB. /// Set maximum accepted payload size. The default limit is 256kB.
#[must_use]
pub fn limit(mut self, limit: usize) -> Self { pub fn limit(mut self, limit: usize) -> Self {
self.limit = limit; self.limit = limit;
self self

View File

@ -241,14 +241,12 @@ pub struct JsonConfig {
impl JsonConfig { impl JsonConfig {
/// Set maximum accepted payload size. By default this limit is 2MB. /// Set maximum accepted payload size. By default this limit is 2MB.
#[must_use]
pub fn limit(mut self, limit: usize) -> Self { pub fn limit(mut self, limit: usize) -> Self {
self.limit = limit; self.limit = limit;
self self
} }
/// Set custom error handler. /// Set custom error handler.
#[must_use]
pub fn error_handler<F>(mut self, f: F) -> Self pub fn error_handler<F>(mut self, f: F) -> Self
where where
F: Fn(JsonPayloadError, &HttpRequest) -> Error + Send + Sync + 'static, F: Fn(JsonPayloadError, &HttpRequest) -> Error + Send + Sync + 'static,
@ -258,7 +256,6 @@ impl JsonConfig {
} }
/// Set predicate for allowed content types. /// Set predicate for allowed content types.
#[must_use]
pub fn content_type<F>(mut self, predicate: F) -> Self pub fn content_type<F>(mut self, predicate: F) -> Self
where where
F: Fn(mime::Mime) -> bool + Send + Sync + 'static, F: Fn(mime::Mime) -> bool + Send + Sync + 'static,
@ -368,7 +365,6 @@ where
} }
/// Set maximum accepted payload size. The default limit is 2MB. /// Set maximum accepted payload size. The default limit is 2MB.
#[must_use]
pub fn limit(self, limit: usize) -> Self { pub fn limit(self, limit: usize) -> Self {
match self { match self {
JsonBody::Body { JsonBody::Body {

View File

@ -47,7 +47,6 @@ pub struct Payload(pub crate::dev::Payload);
impl Payload { impl Payload {
/// Unwrap to inner Payload type. /// Unwrap to inner Payload type.
#[must_use]
pub fn into_inner(self) -> crate::dev::Payload { pub fn into_inner(self) -> crate::dev::Payload {
self.0 self.0
} }
@ -215,7 +214,6 @@ pub struct PayloadConfig {
impl PayloadConfig { impl PayloadConfig {
/// Create new instance with a size limit (in bytes) and no mime type condition. /// Create new instance with a size limit (in bytes) and no mime type condition.
#[must_use]
pub fn new(limit: usize) -> Self { pub fn new(limit: usize) -> Self {
Self { Self {
limit, limit,
@ -224,14 +222,12 @@ impl PayloadConfig {
} }
/// Set maximum accepted payload size in bytes. The default limit is 256kB. /// Set maximum accepted payload size in bytes. The default limit is 256kB.
#[must_use]
pub fn limit(mut self, limit: usize) -> Self { pub fn limit(mut self, limit: usize) -> Self {
self.limit = limit; self.limit = limit;
self self
} }
/// Set required mime type of the request. By default mime type is not enforced. /// Set required mime type of the request. By default mime type is not enforced.
#[must_use]
pub fn mimetype(mut self, mt: Mime) -> Self { pub fn mimetype(mut self, mt: Mime) -> Self {
self.mimetype = Some(mt); self.mimetype = Some(mt);
self self

View File

@ -51,7 +51,6 @@ pub use crate::types::*;
/// .route(web::head().to(|| HttpResponse::MethodNotAllowed())) /// .route(web::head().to(|| HttpResponse::MethodNotAllowed()))
/// ); /// );
/// ``` /// ```
#[must_use]
pub fn resource<T: IntoPattern>(path: T) -> Resource { pub fn resource<T: IntoPattern>(path: T) -> Resource {
Resource::new(path) Resource::new(path)
} }
@ -77,13 +76,11 @@ pub fn resource<T: IntoPattern>(path: T) -> Resource {
/// * /{project_id}/path2 /// * /{project_id}/path2
/// * /{project_id}/path3 /// * /{project_id}/path3
/// ///
#[must_use]
pub fn scope(path: &str) -> Scope { pub fn scope(path: &str) -> Scope {
Scope::new(path) Scope::new(path)
} }
/// Create *route* without configuration. /// Create *route* without configuration.
#[must_use]
pub fn route() -> Route { pub fn route() -> Route {
Route::new() Route::new()
} }
@ -102,7 +99,6 @@ pub fn route() -> Route {
/// In the above example, one `GET` route gets added: /// In the above example, one `GET` route gets added:
/// * /{project_id} /// * /{project_id}
/// ///
#[must_use]
pub fn get() -> Route { pub fn get() -> Route {
method(Method::GET) method(Method::GET)
} }
@ -121,7 +117,6 @@ pub fn get() -> Route {
/// In the above example, one `POST` route gets added: /// In the above example, one `POST` route gets added:
/// * /{project_id} /// * /{project_id}
/// ///
#[must_use]
pub fn post() -> Route { pub fn post() -> Route {
method(Method::POST) method(Method::POST)
} }
@ -140,7 +135,6 @@ pub fn post() -> Route {
/// In the above example, one `PUT` route gets added: /// In the above example, one `PUT` route gets added:
/// * /{project_id} /// * /{project_id}
/// ///
#[must_use]
pub fn put() -> Route { pub fn put() -> Route {
method(Method::PUT) method(Method::PUT)
} }
@ -159,7 +153,6 @@ pub fn put() -> Route {
/// In the above example, one `PATCH` route gets added: /// In the above example, one `PATCH` route gets added:
/// * /{project_id} /// * /{project_id}
/// ///
#[must_use]
pub fn patch() -> Route { pub fn patch() -> Route {
method(Method::PATCH) method(Method::PATCH)
} }
@ -178,7 +171,6 @@ pub fn patch() -> Route {
/// In the above example, one `DELETE` route gets added: /// In the above example, one `DELETE` route gets added:
/// * /{project_id} /// * /{project_id}
/// ///
#[must_use]
pub fn delete() -> Route { pub fn delete() -> Route {
method(Method::DELETE) method(Method::DELETE)
} }
@ -197,7 +189,6 @@ pub fn delete() -> Route {
/// In the above example, one `HEAD` route gets added: /// In the above example, one `HEAD` route gets added:
/// * /{project_id} /// * /{project_id}
/// ///
#[must_use]
pub fn head() -> Route { pub fn head() -> Route {
method(Method::HEAD) method(Method::HEAD)
} }
@ -216,7 +207,6 @@ pub fn head() -> Route {
/// In the above example, one `HEAD` route gets added: /// In the above example, one `HEAD` route gets added:
/// * /{project_id} /// * /{project_id}
/// ///
#[must_use]
pub fn trace() -> Route { pub fn trace() -> Route {
method(Method::TRACE) method(Method::TRACE)
} }
@ -235,7 +225,6 @@ pub fn trace() -> Route {
/// In the above example, one `GET` route gets added: /// In the above example, one `GET` route gets added:
/// * /{project_id} /// * /{project_id}
/// ///
#[must_use]
pub fn method(method: Method) -> Route { pub fn method(method: Method) -> Route {
Route::new().method(method) Route::new().method(method)
} }
@ -254,7 +243,6 @@ pub fn method(method: Method) -> Route {
/// web::to(index)) /// web::to(index))
/// ); /// );
/// ``` /// ```
#[must_use]
pub fn to<F, I, R>(handler: F) -> Route pub fn to<F, I, R>(handler: F) -> Route
where where
F: Handler<I, R>, F: Handler<I, R>,
@ -280,7 +268,6 @@ where
/// .finish(my_service) /// .finish(my_service)
/// ); /// );
/// ``` /// ```
#[must_use]
pub fn service<T: IntoPattern>(path: T) -> WebService { pub fn service<T: IntoPattern>(path: T) -> WebService {
WebService::new(path) WebService::new(path)
} }