Implemented tag output in Message::to_string() which apparently was _still_ a TODO.
This commit is contained in:
parent
f6588cb980
commit
4ec2212dbd
1 changed files with 20 additions and 1 deletions
|
@ -73,8 +73,20 @@ impl Message {
|
||||||
|
|
||||||
/// Converts a Message into a String according to the IRC protocol.
|
/// Converts a Message into a String according to the IRC protocol.
|
||||||
pub fn to_string(&self) -> String {
|
pub fn to_string(&self) -> String {
|
||||||
// TODO: tags
|
|
||||||
let mut ret = String::new();
|
let mut ret = String::new();
|
||||||
|
if let Some(ref tags) = self.tags {
|
||||||
|
ret.push('@');
|
||||||
|
for tag in tags {
|
||||||
|
ret.push_str(&tag.0);
|
||||||
|
if let Some(ref value) = tag.1 {
|
||||||
|
ret.push('=');
|
||||||
|
ret.push_str(value);
|
||||||
|
}
|
||||||
|
ret.push(';');
|
||||||
|
}
|
||||||
|
ret.pop();
|
||||||
|
ret.push(' ');
|
||||||
|
}
|
||||||
if let Some(ref prefix) = self.prefix {
|
if let Some(ref prefix) = self.prefix {
|
||||||
ret.push(':');
|
ret.push(':');
|
||||||
ret.push_str(prefix);
|
ret.push_str(prefix);
|
||||||
|
@ -303,6 +315,13 @@ mod test {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn from_and_to_string() {
|
||||||
|
let message = "@aaa=bbb;ccc;example.com/ddd=eee :test!test@test PRIVMSG test :Testing with \
|
||||||
|
tags!\r\n";
|
||||||
|
assert_eq!(message.parse::<Message>().unwrap().to_string(), message);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn to_message() {
|
fn to_message() {
|
||||||
let message = Message {
|
let message = Message {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue