Fix warnings

This commit is contained in:
Carl Lerche
2017-06-27 12:23:57 -07:00
parent 79aa11ad32
commit fee43a09c8
17 changed files with 61 additions and 59 deletions

View File

@@ -1,11 +1,11 @@
use {frame, proto, Frame, Peer, ConnectionError, StreamId};
use {frame, proto, Peer, ConnectionError, StreamId};
use http;
use futures::{Future, Poll};
use tokio_io::{AsyncRead, AsyncWrite};
use std::fmt;
/// In progress H2 connection binding
pub struct Handshake<T> {
// TODO: unbox
@@ -108,3 +108,9 @@ impl<T> Future for Handshake<T> {
self.inner.poll()
}
}
impl<T: fmt::Debug> fmt::Debug for Handshake<T> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
write!(fmt, "Handshake")
}
}

View File

@@ -9,6 +9,7 @@ pub enum ConnectionError {
Io(io::Error),
}
#[derive(Debug)]
pub struct StreamError(Reason);
#[derive(Debug, PartialEq, Eq, Clone, Copy)]

View File

@@ -1,5 +1,3 @@
use super::Error;
use bytes::{BufMut, BigEndian};
#[derive(Debug, Copy, Clone, PartialEq, Eq)]

View File

@@ -1,6 +1,5 @@
use super::StreamId;
use hpack;
use error::Reason;
use frame::{self, Frame, Head, Kind, Error};
use util::byte_str::ByteStr;
@@ -201,6 +200,10 @@ impl Headers {
response
}
pub fn into_request(self) -> request::Head {
unimplemented!();
}
pub fn encode(self, encoder: &mut hpack::Encoder, dst: &mut BytesMut)
-> Option<Continuation>
{

View File

@@ -1,10 +1,6 @@
use hpack;
use error::{ConnectionError, Reason};
use bytes::{Bytes, BytesMut, BufMut};
use std::io;
/// A helper macro that unpacks a sequence of 4 bytes found in the buffer with
/// the given identifier, starting at the given offset, into the given integer
/// type. Obviously, the integer type should be able to support at least 4
@@ -113,8 +109,6 @@ impl Frame {
impl From<Error> for ConnectionError {
fn from(src: Error) -> ConnectionError {
use self::Error::*;
match src {
// TODO: implement
_ => ConnectionError::Proto(Reason::ProtocolError),

View File

@@ -1,5 +1,5 @@
use frame::{Head, Error};
use super::{head, StreamId};
use super::{StreamId};
#[derive(Debug)]
pub struct Reset {

View File

@@ -1,5 +1,5 @@
use frame::{Frame, Error, Head, Kind};
use bytes::{Bytes, BytesMut, BufMut, BigEndian};
use bytes::{BytesMut, BufMut, BigEndian};
#[derive(Debug, Clone, Default, Eq, PartialEq)]
pub struct Settings {

View File

@@ -1,8 +1,8 @@
use super::{huffman, header as h2_header, Header};
use super::{huffman, Header};
use frame;
use util::byte_str::FromUtf8Error;
use http::{method, header, status, StatusCode, Method};
use http::{method, header, status};
use bytes::{Buf, Bytes, BytesMut};
use std::cmp;
@@ -409,10 +409,6 @@ impl Table {
}
}
fn max_size(&self) -> usize {
self.max_size
}
fn size(&self) -> usize {
self.size
}
@@ -492,33 +488,36 @@ impl Table {
// ===== impl DecoderError =====
impl From<FromUtf8Error> for DecoderError {
fn from(src: FromUtf8Error) -> DecoderError {
fn from(_: FromUtf8Error) -> DecoderError {
// TODO: Better error?
DecoderError::InvalidUtf8
}
}
impl From<header::InvalidValueError> for DecoderError {
fn from(src: header::InvalidValueError) -> DecoderError {
fn from(_: header::InvalidValueError) -> DecoderError {
// TODO: Better error?
DecoderError::InvalidUtf8
}
}
impl From<method::FromBytesError> for DecoderError {
fn from(src: method::FromBytesError) -> DecoderError {
fn from(_: method::FromBytesError) -> DecoderError {
// TODO: Better error
DecoderError::InvalidUtf8
}
}
impl From<header::FromBytesError> for DecoderError {
fn from(src: header::FromBytesError) -> DecoderError {
fn from(_: header::FromBytesError) -> DecoderError {
// TODO: Better error
DecoderError::InvalidUtf8
}
}
impl From<status::FromStrError> for DecoderError {
fn from(src: status::FromStrError) -> DecoderError {
fn from(_: status::FromStrError) -> DecoderError {
// TODO: Better error
DecoderError::InvalidUtf8
}
}

View File

@@ -57,7 +57,7 @@ impl Encoder {
self.size_update = Some(SizeUpdate::One(val));
}
}
Some(SizeUpdate::Two(min, max)) => {
Some(SizeUpdate::Two(min, _)) => {
if val < min {
self.size_update = Some(SizeUpdate::One(val));
} else {
@@ -179,7 +179,6 @@ impl Encoder {
{
match *index {
Index::Indexed(idx, _) => {
let header = self.table.resolve(&index);
try!(encode_int(idx, 7, 0x80, dst));
}
Index::Name(idx, _) => {
@@ -191,7 +190,7 @@ impl Encoder {
header.is_sensitive(),
dst));
}
Index::Inserted(idx) => {
Index::Inserted(_) => {
let header = self.table.resolve(&index);
assert!(!header.is_sensitive());
@@ -323,14 +322,14 @@ fn encode_str(val: &[u8], dst: &mut BytesMut) -> Result<(), EncoderError> {
if encode_int_one_byte(huff_len, 7) {
// Write the string head
dst[idx] = (0x80 | huff_len as u8);
dst[idx] = 0x80 | huff_len as u8;
} else {
// Write the head to a placeholer
let mut buf = [0; 8];
let head_len = {
let mut head_dst = Cursor::new(&mut buf);
encode_int(huff_len, 7, 0x80, &mut head_dst);
try!(encode_int(huff_len, 7, 0x80, &mut head_dst));
head_dst.position() as usize
};
@@ -407,7 +406,6 @@ fn encode_int<B: BufMut>(
}
dst.put_u8(value as u8);
rem -= 1;
Ok(())
}

View File

@@ -1,5 +1,5 @@
use super::DecoderError;
use util::byte_str::{ByteStr, FromUtf8Error};
use util::byte_str::ByteStr;
use http::{Method, StatusCode};
use http::header::{HeaderName, HeaderValue};
@@ -104,7 +104,7 @@ impl Header {
Header::Path(ref v) => {
32 + 5 + v.len()
}
Header::Status(ref v) => {
Header::Status(_) => {
32 + 7 + 3
}
}

View File

@@ -52,7 +52,7 @@ pub fn encode<B: BufMut>(src: &[u8], dst: &mut B) -> Result<(), EncoderError> {
bits |= code << (bits_left - nbits);
bits_left -= nbits;
while (bits_left <= 32) {
while bits_left <= 32 {
if rem == 0 {
return Err(EncoderError::BufferOverflow);
}

View File

@@ -1,8 +1,7 @@
use super::Header;
use fnv::FnvHasher;
use http::method;
use http::header::{self, HeaderName, HeaderValue};
use http::{method, header};
use std::{cmp, mem, usize};
use std::collections::VecDeque;
@@ -193,7 +192,7 @@ impl Table {
return self.index_vacant(header, hash, dist, probe, statik);
} else if pos.hash == hash && self.slots[slot_idx].header.name() == header.name() {
// Matching name, check values
return self.index_occupied(header, hash, pos.index, statik);
return self.index_occupied(header, hash, pos.index);
}
} else {
return self.index_vacant(header, hash, dist, probe, statik);
@@ -206,8 +205,7 @@ impl Table {
fn index_occupied(&mut self,
header: Header,
hash: HashValue,
mut index: usize,
statik: Option<(usize, bool)>)
mut index: usize)
-> Index
{
debug_assert!(self.assert_valid_state("top"));
@@ -255,8 +253,6 @@ impl Table {
// it when inserting the new one...
return Index::InsertedValue(real_idx + DYN_OFFSET, 0);
}
Index::NotIndexed(header)
}
fn index_vacant(&mut self,
@@ -302,7 +298,7 @@ impl Table {
let pos_idx = 0usize.wrapping_sub(self.inserted);
let mut prev = mem::replace(&mut self.indices[probe], Some(Pos {
let prev = mem::replace(&mut self.indices[probe], Some(Pos {
index: pos_idx,
hash: hash,
}));
@@ -513,9 +509,15 @@ impl Table {
}
}
/// Checks that the internal map state is correct
#[cfg(not(test))]
fn assert_valid_state(&self, _: &'static str) -> bool {
true
}
#[cfg(test)]
fn assert_valid_state(&self, msg: &'static str) -> bool {
/*
// Checks that the internal map structure is valid
//
// Ensure all hash codes in indices match the associated slot
for pos in &self.indices {
if let Some(pos) = *pos {
@@ -596,7 +598,6 @@ impl Table {
}
// TODO: Ensure linked lists are correct: no cycles, etc...
*/
true
}
@@ -715,7 +716,7 @@ fn index_static(header: &Header) -> Option<(usize, bool)> {
_ => None,
}
}
Header::Authority(ref v) => Some((1, false)),
Header::Authority(_) => Some((1, false)),
Header::Method(ref v) => {
match *v {
method::GET => Some((2, true)),

View File

@@ -1,4 +1,5 @@
#![allow(warnings)]
// #![allow(warnings)]
#![deny(missing_debug_implementations)]
#[macro_use]
extern crate futures;

View File

@@ -4,7 +4,7 @@ use proto::{self, ReadySink, State};
use tokio_io::{AsyncRead, AsyncWrite};
use http::{self, request, response};
use http::{request};
use futures::*;
@@ -92,7 +92,6 @@ impl<T, P> Stream for Connection<T, P>
}
Some(frame) => panic!("unexpected frame; frame={:?}", frame),
None => return Ok(Async::Ready(None)),
_ => unimplemented!(),
};
Ok(Async::Ready(Some(frame)))
@@ -144,6 +143,7 @@ impl<T, P> Sink for Connection<T, P>
Ok(AsyncSink::Ready)
}
/*
Frame::Trailers { id, headers } => {
unimplemented!();
}
@@ -156,6 +156,8 @@ impl<T, P> Sink for Connection<T, P>
Frame::Error { id, error } => {
unimplemented!();
}
*/
_ => unimplemented!(),
}
}

View File

@@ -5,12 +5,12 @@ use proto::ReadySink;
use futures::*;
use bytes::{Bytes, BytesMut, Buf};
use bytes::Bytes;
use tokio_io::{AsyncRead};
use tokio_io::codec::length_delimited;
use std::io::{self, Write, Cursor};
use std::io::{self, Cursor};
#[derive(Debug)]
pub struct FramedRead<T> {
@@ -26,7 +26,7 @@ pub struct FramedRead<T> {
#[derive(Debug)]
enum Partial {
Headers(frame::Headers),
PushPromise(frame::PushPromise),
// PushPromise(frame::PushPromise),
}
impl<T> FramedRead<T>
@@ -113,7 +113,7 @@ impl<T> Stream for FramedRead<T>
fn poll(&mut self) -> Poll<Option<Frame>, ConnectionError> {
loop {
let mut bytes = match try_ready!(self.inner.poll()) {
let bytes = match try_ready!(self.inner.poll()) {
Some(bytes) => bytes.freeze(),
None => return Ok(Async::Ready(None)),
};

View File

@@ -1,11 +1,10 @@
use {hpack, ConnectionError, Reason};
use frame::{self, Frame, Error};
use {hpack, ConnectionError};
use frame::{self, Frame};
use proto::ReadySink;
use futures::*;
use tokio_io::{AsyncRead, AsyncWrite};
use bytes::{Bytes, BytesMut, Buf, BufMut};
use http::header::{self, HeaderValue};
use bytes::{BytesMut, Buf, BufMut};
use std::cmp;
use std::io::{self, Cursor};
@@ -110,6 +109,7 @@ impl<T: AsyncWrite> Sink for FramedWrite<T> {
}
}
Frame::PushPromise(v) => {
debug!("unimplemented PUSH_PROMISE write; frame={:?}", v);
unimplemented!();
}
Frame::Settings(v) => {

View File

@@ -8,9 +8,9 @@ pub struct ByteStr {
bytes: Bytes,
}
#[derive(Debug)]
pub struct FromUtf8Error {
err: Utf8Error,
val: Bytes,
}
impl ByteStr {
@@ -28,7 +28,6 @@ impl ByteStr {
if let Err(e) = str::from_utf8(&bytes[..]) {
return Err(FromUtf8Error {
err: e,
val: bytes,
});
}