xmpp_codec: add Packet::Text

This commit is contained in:
Astro 2017-06-19 02:17:06 +02:00
parent 014633d119
commit 2e0dff5153

View file

@ -50,6 +50,7 @@ pub enum Packet {
Error(Box<std::error::Error>), Error(Box<std::error::Error>),
StreamStart(HashMap<String, String>), StreamStart(HashMap<String, String>),
Stanza(xml::Element), Stanza(xml::Element),
Text(String),
StreamEnd, StreamEnd,
} }
@ -155,6 +156,8 @@ impl Encoder for XMPPCodec {
}, },
Packet::Stanza(stanza) => Packet::Stanza(stanza) =>
write!(dst, "{}", stanza), write!(dst, "{}", stanza),
Packet::Text(text) =>
write!(dst, "{}", xml::escape(&text)),
// TODO: Implement all // TODO: Implement all
_ => Ok(()) _ => Ok(())
} }