From cb91dd274af0a7486177c824b9744d28b43849b9 Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Fri, 29 Mar 2019 08:49:08 -0700 Subject: [PATCH] buf: impl Error for CollectVecError (#1010) --- tokio-buf/src/util/from.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tokio-buf/src/util/from.rs b/tokio-buf/src/util/from.rs index 1c09e6412..debebb160 100644 --- a/tokio-buf/src/util/from.rs +++ b/tokio-buf/src/util/from.rs @@ -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`. @@ -134,3 +136,27 @@ impl FromBufStream 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" + } +}