Skip to content

Commit

Permalink
Merge pull request #37 from ThinkChaos/cleanup
Browse files Browse the repository at this point in the history
Fix warnings and remove unnecessary features
  • Loading branch information
sgodwincs authored Jun 13, 2020
2 parents 0b2f133 + 213105a commit 19205ae
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 24 deletions.
11 changes: 9 additions & 2 deletions rtsp-2/src/header/types/accept.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::convert::TryFrom;
use std::f32;
use std::fmt::{Error, Formatter};
use std::hash::Hash;
use std::hash::Hasher;
use std::iter::{once, FromIterator};
use std::ops::{Deref, DerefMut};
use std::str;
Expand Down Expand Up @@ -266,7 +265,15 @@ impl<'quality> TryFrom<&'quality str> for QualityParam {

impl QualityParam {
pub fn new(q_value: f32) -> Self {
let q_value = q_value.clamp(0.0_f32, 1.0_f32);
// clamp value
let q_value = if q_value < 0.0 {
0.0
} else if q_value > 1.0 {
1.0
} else {
q_value
};

QualityParam(q_value.to_bits())
}
}
Expand Down
2 changes: 1 addition & 1 deletion rtsp-2/src/header/types/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::convert::Infallible;
use std::error::Error;
use std::fmt::{self, Display, Formatter};
use std::iter::once;
use std::ops::{Deref, DerefMut};
use std::ops::Deref;

use crate::header::common::date::{self, DateTimeError};
use crate::header::map::TypedHeader;
Expand Down
2 changes: 1 addition & 1 deletion rtsp-2/src/header/types/expires.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::convert::Infallible;
use std::error::Error;
use std::fmt::{self, Display, Formatter};
use std::iter::once;
use std::ops::{Deref, DerefMut};
use std::ops::Deref;

use crate::header::common::date::{self, DateTimeError};
use crate::header::map::TypedHeader;
Expand Down
2 changes: 1 addition & 1 deletion rtsp-2/src/header/types/transport/interleaved.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,4 @@ fn parse_channel(value: &[u8]) -> Result<(u8, &[u8]), InterleavedError> {
} else {
Ok((channel, &value[digits_found..]))
}
}
}
3 changes: 0 additions & 3 deletions rtsp-2/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#![feature(clamp)]
#![feature(int_error_matching)]
#![feature(non_exhaustive)]
#![feature(type_alias_enum_variants)]

mod syntax;

Expand Down
1 change: 0 additions & 1 deletion rtsp-2/src/protocol/connection/receiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use tokio_timer::Delay;
use crate::header::map::HeaderMapExtension;
use crate::header::types::CSeq;
use crate::protocol::codec::decoder::request::DecodeError as RequestDecodeError;
use crate::protocol::codec::decoder::response::DecodeError as ResponseDecodeError;
use crate::protocol::codec::{CodecEvent, DecodeError, Message, ProtocolError};
use crate::protocol::connection::pending::{PendingRequestResponse, PendingRequestUpdate};
use crate::protocol::connection::sender::SenderHandle;
Expand Down
2 changes: 1 addition & 1 deletion rtsp-2/src/protocol/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub struct EmptyService;
impl Service<Request<BytesMut>> for EmptyService {
type Response = Response<BytesMut>;
type Error = io::Error;
type Future = Box<Future<Item = Self::Response, Error = Self::Error> + Send + 'static>;
type Future = Box<dyn Future<Item = Self::Response, Error = Self::Error> + Send + 'static>;

fn call(&mut self, _: Request<BytesMut>) -> Self::Future {
Box::new(future::empty())
Expand Down
11 changes: 2 additions & 9 deletions rtsp-2/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,20 +121,13 @@ impl ConnectionService {
}
Err(_) => return Box::new(future::ok(BAD_REQUEST_RESPONSE.clone())),
}

Box::new(future::ok(
Response::<()>::builder()
.with_body(BytesMut::new())
.build()
.unwrap(),
))
}
}

impl Service<Request<BytesMut>> for ConnectionService {
type Response = Response<BytesMut>;
type Error = Box<Error + Send + 'static>;
type Future = Box<Future<Item = Self::Response, Error = Self::Error> + Send + 'static>;
type Error = Box<dyn Error + Send + 'static>;
type Future = Box<dyn Future<Item = Self::Response, Error = Self::Error> + Send + 'static>;

fn call(&mut self, mut request: Request<BytesMut>) -> Self::Future {
request.uri_mut().normalize();
Expand Down
10 changes: 5 additions & 5 deletions rtsp-2/src/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,11 @@ impl StatusCode {
use self::StatusCodeClass::*;

match u16::from(self) {
100...199 => Informational,
200...299 => Success,
300...399 => Redirection,
400...499 => ClientError,
500...599 => ServerError,
100..=199 => Informational,
200..=299 => Success,
300..=399 => Redirection,
400..=499 => ClientError,
500..=599 => ServerError,
_ => panic!("status code with invalid class"),
}
}
Expand Down

0 comments on commit 19205ae

Please sign in to comment.