1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-11-26 03:21:08 +00:00

improve BoxBody Debug impl

This commit is contained in:
Rob Ede 2021-12-17 19:16:42 +00:00
parent 57ea322ce5
commit aa31086af5
No known key found for this signature in database
GPG key ID: 97C636207D3EF933

View file

@ -11,6 +11,7 @@ use super::{BodySize, MessageBody, MessageBodyMapErr};
use crate::body; use crate::body;
/// A boxed message body with boxed errors. /// A boxed message body with boxed errors.
#[derive(Debug)]
pub struct BoxBody(BoxBodyInner); pub struct BoxBody(BoxBodyInner);
enum BoxBodyInner { enum BoxBodyInner {
@ -19,6 +20,16 @@ enum BoxBodyInner {
Stream(Pin<Box<dyn MessageBody<Error = Box<dyn StdError>>>>), Stream(Pin<Box<dyn MessageBody<Error = Box<dyn StdError>>>>),
} }
impl fmt::Debug for BoxBodyInner {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::None(arg0) => f.debug_tuple("None").field(arg0).finish(),
Self::Bytes(arg0) => f.debug_tuple("Bytes").field(arg0).finish(),
Self::Stream(_) => f.debug_tuple("Stream").field(&"dyn MessageBody").finish(),
}
}
}
impl BoxBody { impl BoxBody {
/// Same as `MessageBody::boxed`. /// Same as `MessageBody::boxed`.
/// ///
@ -48,13 +59,6 @@ impl BoxBody {
} }
} }
impl fmt::Debug for BoxBody {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// TODO show BoxBodyInner
f.write_str("BoxBody(dyn MessageBody)")
}
}
impl MessageBody for BoxBody { impl MessageBody for BoxBody {
type Error = Box<dyn StdError>; type Error = Box<dyn StdError>;