mirror of
https://github.com/actix/actix-web.git
synced 2024-11-14 04:41:15 +00:00
improve BoxBody Debug impl
This commit is contained in:
parent
57ea322ce5
commit
aa31086af5
1 changed files with 11 additions and 7 deletions
|
@ -11,6 +11,7 @@ use super::{BodySize, MessageBody, MessageBodyMapErr};
|
|||
use crate::body;
|
||||
|
||||
/// A boxed message body with boxed errors.
|
||||
#[derive(Debug)]
|
||||
pub struct BoxBody(BoxBodyInner);
|
||||
|
||||
enum BoxBodyInner {
|
||||
|
@ -19,6 +20,16 @@ enum BoxBodyInner {
|
|||
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 {
|
||||
/// 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 {
|
||||
type Error = Box<dyn StdError>;
|
||||
|
||||
|
|
Loading…
Reference in a new issue