Use rustfmt to enforce consistent formatting
This change adds a .rustfmt.toml that includes ALL supported settings, 12 of which we have overridden to attempt to cater to our own proclivities. rustfmt is checked in the rust-nightly CI job.
This commit is contained in:
@@ -2,12 +2,12 @@ mod error;
|
||||
mod framed_read;
|
||||
mod framed_write;
|
||||
|
||||
pub use self::error::{SendError, RecvError, UserError};
|
||||
pub use self::error::{RecvError, SendError, UserError};
|
||||
|
||||
use self::framed_read::FramedRead;
|
||||
use self::framed_write::FramedWrite;
|
||||
|
||||
use frame::{self, Frame, Data};
|
||||
use frame::{self, Data, Frame};
|
||||
|
||||
use futures::*;
|
||||
|
||||
@@ -24,16 +24,14 @@ pub struct Codec<T, B> {
|
||||
}
|
||||
|
||||
impl<T, B> Codec<T, B>
|
||||
where T: AsyncRead + AsyncWrite,
|
||||
B: Buf,
|
||||
where
|
||||
T: AsyncRead + AsyncWrite,
|
||||
B: Buf,
|
||||
{
|
||||
/// Returns a new `Codec` with the default max frame size
|
||||
#[inline]
|
||||
pub fn new(io: T) -> Self {
|
||||
Self::with_max_recv_frame_size(
|
||||
io,
|
||||
frame::DEFAULT_MAX_FRAME_SIZE as usize
|
||||
)
|
||||
Self::with_max_recv_frame_size(io, frame::DEFAULT_MAX_FRAME_SIZE as usize)
|
||||
}
|
||||
|
||||
/// Returns a new `Codec` with the given maximum frame size
|
||||
@@ -52,12 +50,13 @@ impl<T, B> Codec<T, B>
|
||||
|
||||
let inner = FramedRead::new(delimited);
|
||||
|
||||
Codec { inner }
|
||||
Codec {
|
||||
inner,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, B> Codec<T, B> {
|
||||
|
||||
/// Updates the max received frame size.
|
||||
///
|
||||
/// The change takes effect the next time a frame is decoded. In other
|
||||
@@ -68,7 +67,6 @@ impl<T, B> Codec<T, B> {
|
||||
pub fn set_max_recv_frame_size(&mut self, val: usize) {
|
||||
// TODO: should probably make some assertions about max frame size...
|
||||
self.inner.set_max_frame_size(val)
|
||||
|
||||
}
|
||||
|
||||
/// Returns the current max received frame size setting.
|
||||
@@ -112,8 +110,9 @@ impl<T, B> Codec<T, B> {
|
||||
}
|
||||
|
||||
impl<T, B> Codec<T, B>
|
||||
where T: AsyncWrite,
|
||||
B: Buf,
|
||||
where
|
||||
T: AsyncWrite,
|
||||
B: Buf,
|
||||
{
|
||||
/// Returns `Ready` when the codec can buffer a frame
|
||||
pub fn poll_ready(&mut self) -> Poll<(), io::Error> {
|
||||
@@ -126,8 +125,7 @@ impl<T, B> Codec<T, B>
|
||||
/// accepted.
|
||||
///
|
||||
/// TODO: Rename this to avoid conflicts with Sink::buffer
|
||||
pub fn buffer(&mut self, item: Frame<B>) -> Result<(), UserError>
|
||||
{
|
||||
pub fn buffer(&mut self, item: Frame<B>) -> Result<(), UserError> {
|
||||
self.framed_write().buffer(item)
|
||||
}
|
||||
|
||||
@@ -143,7 +141,8 @@ impl<T, B> Codec<T, B>
|
||||
}
|
||||
|
||||
impl<T, B> Stream for Codec<T, B>
|
||||
where T: AsyncRead,
|
||||
where
|
||||
T: AsyncRead,
|
||||
{
|
||||
type Item = Frame;
|
||||
type Error = RecvError;
|
||||
@@ -154,8 +153,9 @@ impl<T, B> Stream for Codec<T, B>
|
||||
}
|
||||
|
||||
impl<T, B> Sink for Codec<T, B>
|
||||
where T: AsyncWrite,
|
||||
B: Buf,
|
||||
where
|
||||
T: AsyncWrite,
|
||||
B: Buf,
|
||||
{
|
||||
type SinkItem = Frame<B>;
|
||||
type SinkError = SendError;
|
||||
@@ -182,7 +182,8 @@ impl<T, B> Sink for Codec<T, B>
|
||||
|
||||
// TODO: remove (or improve) this
|
||||
impl<T> From<T> for Codec<T, ::std::io::Cursor<::bytes::Bytes>>
|
||||
where T: AsyncRead + AsyncWrite,
|
||||
where
|
||||
T: AsyncRead + AsyncWrite,
|
||||
{
|
||||
fn from(src: T) -> Self {
|
||||
Self::new(src)
|
||||
|
||||
Reference in New Issue
Block a user