summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2014-09-08 11:54:51 -0400
committerJesse Luehrs <doy@tozt.net>2014-09-08 11:54:51 -0400
commit318259f54ee614d56aab0f434606a990645eee42 (patch)
tree96eed1a2a2141cfc70fcf6ec9dd1f4bce91a3059 /src
parentcb035e9de40b5b1e5a8a5e862ae9dd6a9da68d06 (diff)
downloadrust-irc-318259f54ee614d56aab0f434606a990645eee42.tar.gz
rust-irc-318259f54ee614d56aab0f434606a990645eee42.zip
also provide a method to get a String out
not using this as the default ToStr because it's less easy to read
Diffstat (limited to 'src')
-rw-r--r--src/message.rs9
1 files changed, 9 insertions, 0 deletions
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<String>,
@@ -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<String> {
let mut offset = 0;
let len = params.len();