rustfmt: add trailing commas in match arms, set fn call to block stle (#85)

This commit is contained in:
Sean McArthur
2017-09-12 19:29:06 -07:00
committed by Carl Lerche
parent de1edf4873
commit f7d14861e5
37 changed files with 894 additions and 973 deletions

View File

@@ -70,24 +70,24 @@ impl<T> FramedRead<T> {
let res = frame::Settings::load(head, &bytes[frame::HEADER_LEN..]);
res.map_err(|_| Connection(ProtocolError))?.into()
}
},
Kind::Ping => {
let res = frame::Ping::load(head, &bytes[frame::HEADER_LEN..]);
res.map_err(|_| Connection(ProtocolError))?.into()
}
},
Kind::WindowUpdate => {
let res = frame::WindowUpdate::load(head, &bytes[frame::HEADER_LEN..]);
res.map_err(|_| Connection(ProtocolError))?.into()
}
},
Kind::Data => {
let _ = bytes.split_to(frame::HEADER_LEN);
let res = frame::Data::load(head, bytes.freeze());
// TODO: Should this always be connection level? Probably not...
res.map_err(|_| Connection(ProtocolError))?.into()
}
},
Kind::Headers => {
// Drop the frame header
// TODO: Change to drain: carllerche/bytes#130
@@ -101,23 +101,23 @@ impl<T> FramedRead<T> {
// treat this as a stream error (Section 5.4.2) of type
// `PROTOCOL_ERROR`.
return Err(Stream {
id: head.stream_id(),
reason: ProtocolError,
});
}
id: head.stream_id(),
reason: ProtocolError,
});
},
_ => return Err(Connection(ProtocolError)),
};
if headers.is_end_headers() {
// Load the HPACK encoded headers & return the frame
match headers.load_hpack(payload, &mut self.hpack) {
Ok(_) => {}
Ok(_) => {},
Err(frame::Error::MalformedMessage) => {
return Err(Stream {
id: head.stream_id(),
reason: ProtocolError,
});
}
id: head.stream_id(),
reason: ProtocolError,
});
},
Err(_) => return Err(Connection(ProtocolError)),
}
@@ -125,25 +125,25 @@ impl<T> FramedRead<T> {
} else {
// Defer loading the frame
self.partial = Some(Partial {
frame: Continuable::Headers(headers),
buf: payload,
});
frame: Continuable::Headers(headers),
buf: payload,
});
return Ok(None);
}
}
},
Kind::Reset => {
let res = frame::Reset::load(head, &bytes[frame::HEADER_LEN..]);
res.map_err(|_| Connection(ProtocolError))?.into()
}
},
Kind::GoAway => {
let res = frame::GoAway::load(&bytes[frame::HEADER_LEN..]);
res.map_err(|_| Connection(ProtocolError))?.into()
}
},
Kind::PushPromise => {
let res = frame::PushPromise::load(head, &bytes[frame::HEADER_LEN..]);
res.map_err(|_| Connection(ProtocolError))?.into()
}
},
Kind::Priority => {
if head.stream_id() == 0 {
// Invalid stream identifier
@@ -157,13 +157,13 @@ impl<T> FramedRead<T> {
// treat this as a stream error (Section 5.4.2) of type
// `PROTOCOL_ERROR`.
return Err(Stream {
id: head.stream_id(),
reason: ProtocolError,
});
}
id: head.stream_id(),
reason: ProtocolError,
});
},
Err(_) => return Err(Connection(ProtocolError)),
}
}
},
Kind::Continuation => {
// TODO: Un-hack this
let end_of_headers = (head.flag() & 0x4) == 0x4;
@@ -189,24 +189,24 @@ impl<T> FramedRead<T> {
}
match frame.load_hpack(partial.buf, &mut self.hpack) {
Ok(_) => {}
Ok(_) => {},
Err(frame::Error::MalformedMessage) => {
return Err(Stream {
id: head.stream_id(),
reason: ProtocolError,
});
}
id: head.stream_id(),
reason: ProtocolError,
});
},
Err(_) => return Err(Connection(ProtocolError)),
}
frame.into()
}
},
}
}
},
Kind::Unknown => {
// Unknown frames are ignored
return Ok(None);
}
},
};
Ok(Some(frame))

View File

@@ -120,32 +120,32 @@ where
// Save off the last frame...
self.last_data_frame = Some(v);
}
}
},
Frame::Headers(v) => {
if let Some(continuation) = v.encode(&mut self.hpack, self.buf.get_mut()) {
self.next = Some(Next::Continuation(continuation));
}
}
},
Frame::PushPromise(v) => {
debug!("unimplemented PUSH_PROMISE write; frame={:?}", v);
unimplemented!();
}
},
Frame::Settings(v) => {
v.encode(self.buf.get_mut());
trace!("encoded settings; rem={:?}", self.buf.remaining());
}
},
Frame::GoAway(v) => {
v.encode(self.buf.get_mut());
trace!("encoded go_away; rem={:?}", self.buf.remaining());
}
},
Frame::Ping(v) => {
v.encode(self.buf.get_mut());
trace!("encoded ping; rem={:?}", self.buf.remaining());
}
},
Frame::WindowUpdate(v) => {
v.encode(self.buf.get_mut());
trace!("encoded window_update; rem={:?}", self.buf.remaining());
}
},
Frame::Priority(_) => {
/*
@@ -153,11 +153,11 @@ where
trace!("encoded priority; rem={:?}", self.buf.remaining());
*/
unimplemented!();
}
},
Frame::Reset(v) => {
v.encode(self.buf.get_mut());
trace!("encoded reset; rem={:?}", self.buf.remaining());
}
},
}
Ok(())
@@ -172,10 +172,10 @@ where
Some(Next::Data(ref mut frame)) => {
let mut buf = Buf::by_ref(&mut self.buf).chain(frame.payload_mut());
try_ready!(self.inner.write_buf(&mut buf));
}
},
_ => {
try_ready!(self.inner.write_buf(&mut self.buf));
}
},
}
}
@@ -183,11 +183,11 @@ where
match self.next.take() {
Some(Next::Data(frame)) => {
self.last_data_frame = Some(frame);
}
},
Some(Next::Continuation(_)) => {
unimplemented!();
}
None => {}
},
None => {},
}
trace!("flushing buffer");