diff --git a/src/protocol/message.rs b/src/protocol/message.rs index 8ee3eac..a4cbc82 100644 --- a/src/protocol/message.rs +++ b/src/protocol/message.rs @@ -303,6 +303,12 @@ impl From> for Message { } } +impl Into> for Message { + fn into(self) -> Vec { + self.into_data() + } +} + impl fmt::Display for Message { fn fmt(&self, f: &mut fmt::Formatter) -> StdResult<(), fmt::Error> { if let Ok(string) = self.to_text() { @@ -343,6 +349,15 @@ mod tests { assert!(msg.into_text().is_err()); } + #[test] + fn binary_convert_into_vec() { + let bin = vec![6u8, 7, 8, 9, 10, 241]; + let bin_copy = bin.clone(); + let msg = Message::from(bin); + let serialized: Vec = msg.into(); + assert_eq!(bin_copy, serialized); + } + #[test] fn text_convert() { let s = "kiwotsukete";