Skip to content

Commit

Permalink
Merge pull request #16 from thomaseizinger/feat/message-class-display
Browse files Browse the repository at this point in the history
Add `fmt::Display` implementation for `MessageClass`
  • Loading branch information
sile authored Sep 18, 2023
2 parents 908d705 + 3231e19 commit 814838b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use bytecodec::bytes::{BytesEncoder, CopyableBytesDecoder};
use bytecodec::combinator::{Collect, Length, Peekable, PreEncode, Repeat};
use bytecodec::fixnum::{U16beDecoder, U16beEncoder, U32beDecoder, U32beEncoder};
use bytecodec::{ByteCount, Decode, Encode, Eos, Error, ErrorKind, Result, SizedEncode};
use std::vec;
use std::{fmt, vec};
use trackable::error::ErrorKindExt;

/// Message decoded by [`MessageDecoder`].
Expand All @@ -35,6 +35,17 @@ impl MessageClass {
}
}

impl fmt::Display for MessageClass {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
MessageClass::Request => write!(f, "request"),
MessageClass::Indication => write!(f, "indication"),
MessageClass::SuccessResponse => write!(f, "success response"),
MessageClass::ErrorResponse => write!(f, "error response"),
}
}
}

/// STUN message.
///
/// # NOTE: Binary Format of STUN Messages
Expand Down

0 comments on commit 814838b

Please sign in to comment.