mirror of
https://github.com/actix/actix-web.git
synced 2025-01-20 05:58:08 +00:00
address clippy lints
This commit is contained in:
parent
6d710629af
commit
dc23559f23
4 changed files with 24 additions and 20 deletions
|
@ -1,7 +1,6 @@
|
||||||
use std::convert::{From, Into};
|
use std::convert::{From, Into};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
use self::OpCode::*;
|
|
||||||
/// Operation codes as part of RFC6455.
|
/// Operation codes as part of RFC6455.
|
||||||
#[derive(Debug, Eq, PartialEq, Clone, Copy)]
|
#[derive(Debug, Eq, PartialEq, Clone, Copy)]
|
||||||
pub enum OpCode {
|
pub enum OpCode {
|
||||||
|
@ -29,6 +28,7 @@ pub enum OpCode {
|
||||||
|
|
||||||
impl fmt::Display for OpCode {
|
impl fmt::Display for OpCode {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
use self::OpCode::*;
|
||||||
match *self {
|
match *self {
|
||||||
Continue => write!(f, "CONTINUE"),
|
Continue => write!(f, "CONTINUE"),
|
||||||
Text => write!(f, "TEXT"),
|
Text => write!(f, "TEXT"),
|
||||||
|
@ -41,9 +41,10 @@ impl fmt::Display for OpCode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<u8> for OpCode {
|
impl From<OpCode> for u8 {
|
||||||
fn into(self) -> u8 {
|
fn from(op: OpCode) -> u8 {
|
||||||
match self {
|
use self::OpCode::*;
|
||||||
|
match op {
|
||||||
Continue => 0,
|
Continue => 0,
|
||||||
Text => 1,
|
Text => 1,
|
||||||
Binary => 2,
|
Binary => 2,
|
||||||
|
@ -60,6 +61,7 @@ impl Into<u8> for OpCode {
|
||||||
|
|
||||||
impl From<u8> for OpCode {
|
impl From<u8> for OpCode {
|
||||||
fn from(byte: u8) -> OpCode {
|
fn from(byte: u8) -> OpCode {
|
||||||
|
use self::OpCode::*;
|
||||||
match byte {
|
match byte {
|
||||||
0 => Continue,
|
0 => Continue,
|
||||||
1 => Text,
|
1 => Text,
|
||||||
|
@ -72,7 +74,6 @@ impl From<u8> for OpCode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use self::CloseCode::*;
|
|
||||||
/// Status code used to indicate why an endpoint is closing the `WebSocket`
|
/// Status code used to indicate why an endpoint is closing the `WebSocket`
|
||||||
/// connection.
|
/// connection.
|
||||||
#[derive(Debug, Eq, PartialEq, Clone, Copy)]
|
#[derive(Debug, Eq, PartialEq, Clone, Copy)]
|
||||||
|
@ -138,9 +139,10 @@ pub enum CloseCode {
|
||||||
Other(u16),
|
Other(u16),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<u16> for CloseCode {
|
impl From<CloseCode> for u16 {
|
||||||
fn into(self) -> u16 {
|
fn from(code: CloseCode) -> u16 {
|
||||||
match self {
|
use self::CloseCode::*;
|
||||||
|
match code {
|
||||||
Normal => 1000,
|
Normal => 1000,
|
||||||
Away => 1001,
|
Away => 1001,
|
||||||
Protocol => 1002,
|
Protocol => 1002,
|
||||||
|
@ -161,6 +163,7 @@ impl Into<u16> for CloseCode {
|
||||||
|
|
||||||
impl From<u16> for CloseCode {
|
impl From<u16> for CloseCode {
|
||||||
fn from(code: u16) -> CloseCode {
|
fn from(code: u16) -> CloseCode {
|
||||||
|
use self::CloseCode::*;
|
||||||
match code {
|
match code {
|
||||||
1000 => Normal,
|
1000 => Normal,
|
||||||
1001 => Away,
|
1001 => Away,
|
||||||
|
@ -185,6 +188,7 @@ impl From<u16> for CloseCode {
|
||||||
pub struct CloseReason {
|
pub struct CloseReason {
|
||||||
/// Exit code
|
/// Exit code
|
||||||
pub code: CloseCode,
|
pub code: CloseCode,
|
||||||
|
|
||||||
/// Optional description of the exit code
|
/// Optional description of the exit code
|
||||||
pub description: Option<String>,
|
pub description: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,18 +33,18 @@ pub(crate) enum PrepForSendingError {
|
||||||
Http(HttpError),
|
Http(HttpError),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<FreezeRequestError> for PrepForSendingError {
|
impl From<PrepForSendingError> for FreezeRequestError {
|
||||||
fn into(self) -> FreezeRequestError {
|
fn from(err: PrepForSendingError) -> FreezeRequestError {
|
||||||
match self {
|
match err {
|
||||||
PrepForSendingError::Url(e) => FreezeRequestError::Url(e),
|
PrepForSendingError::Url(e) => FreezeRequestError::Url(e),
|
||||||
PrepForSendingError::Http(e) => FreezeRequestError::Http(e),
|
PrepForSendingError::Http(e) => FreezeRequestError::Http(e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<SendRequestError> for PrepForSendingError {
|
impl From<PrepForSendingError> for SendRequestError {
|
||||||
fn into(self) -> SendRequestError {
|
fn from(err: PrepForSendingError) -> SendRequestError {
|
||||||
match self {
|
match err {
|
||||||
PrepForSendingError::Url(e) => SendRequestError::Url(e),
|
PrepForSendingError::Url(e) => SendRequestError::Url(e),
|
||||||
PrepForSendingError::Http(e) => SendRequestError::Http(e),
|
PrepForSendingError::Http(e) => SendRequestError::Http(e),
|
||||||
}
|
}
|
||||||
|
|
|
@ -416,9 +416,9 @@ impl<B> ServiceResponse<B> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<B> Into<Response<B>> for ServiceResponse<B> {
|
impl<B> From<ServiceResponse<B>> for Response<B> {
|
||||||
fn into(self) -> Response<B> {
|
fn into(res: ServiceResponse<B>) -> Response<B> {
|
||||||
self.response
|
res.response
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -121,13 +121,13 @@ pub enum EitherExtractError<A, B> {
|
||||||
Extract(A, B),
|
Extract(A, B),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<A, B> Into<Error> for EitherExtractError<A, B>
|
impl<A, B> From<EitherExtractError<A, B>> for Error
|
||||||
where
|
where
|
||||||
A: Into<Error>,
|
A: Into<Error>,
|
||||||
B: Into<Error>,
|
B: Into<Error>,
|
||||||
{
|
{
|
||||||
fn into(self) -> Error {
|
fn into(err: EitherExtractError<A, B>) -> Error {
|
||||||
match self {
|
match err {
|
||||||
EitherExtractError::Bytes(err) => err,
|
EitherExtractError::Bytes(err) => err,
|
||||||
EitherExtractError::Extract(a_err, _b_err) => a_err.into(),
|
EitherExtractError::Extract(a_err, _b_err) => a_err.into(),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue