From 318259f54ee614d56aab0f434606a990645eee42 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Mon, 8 Sep 2014 11:54:51 -0400 Subject: also provide a method to get a String out not using this as the default ToStr because it's less easy to read --- src/message.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src') diff --git a/src/message.rs b/src/message.rs index 9bd6b6f..b90cafb 100644 --- a/src/message.rs +++ b/src/message.rs @@ -1,5 +1,7 @@ use constants::MessageType; +use std::io; + #[deriving(PartialEq, Eq, Show)] pub struct Message { from: Option, @@ -64,6 +66,13 @@ impl Message { w.flush(); } + pub fn to_protocol_string (&self) -> String { + let mut w = io::MemWriter::new(); + self.write_protocol_string(&mut w); + // XXX error handling, encoding + String::from_utf8(w.unwrap()).unwrap() + } + fn parse_params(params: &str) -> Vec { let mut offset = 0; let len = params.len(); -- cgit v1.2.3-54-g00ecf