Skip to content

Commit

Permalink
buf: impl Error for CollectVecError (#1010)
Browse files Browse the repository at this point in the history
  • Loading branch information
carllerche authored Mar 29, 2019
1 parent ea7178b commit cb91dd2
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tokio-buf/src/util/from.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ use SizeHint;

use bytes::{Buf, BufMut, Bytes};

use std::error::Error;
use std::fmt;
use std::usize;

/// Conversion from a `BufStream`.
Expand Down Expand Up @@ -134,3 +136,27 @@ impl<T: Buf> FromBufStream<T> for Bytes {
Ok(builder.into())
}
}

impl fmt::Display for CollectVecError {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
write!(fmt, "BufStream is too big")
}
}

impl Error for CollectVecError {
fn description(&self) -> &str {
"BufStream too big"
}
}

impl fmt::Display for CollectBytesError {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
write!(fmt, "BufStream too big")
}
}

impl Error for CollectBytesError {
fn description(&self) -> &str {
"BufStream too big"
}
}

0 comments on commit cb91dd2

Please sign in to comment.