mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
tokio-xmpp: remove outdated WriteBytes wrapper
This commit is contained in:
parent
3931a44d50
commit
8d0b55db7e
1 changed files with 1 additions and 25 deletions
|
@ -137,7 +137,7 @@ impl Encoder<Packet> for XMPPCodec {
|
|||
write!(dst, "{}", buf).map_err(to_io_err)
|
||||
}
|
||||
Packet::Stanza(stanza) => stanza
|
||||
.write_to(&mut WriteBytes::new(dst))
|
||||
.write_to(dst)
|
||||
.and_then(|_| {
|
||||
debug!(">> {:?}", dst);
|
||||
Ok(())
|
||||
|
@ -176,30 +176,6 @@ pub fn escape(input: &str) -> String {
|
|||
result
|
||||
}
|
||||
|
||||
/// BytesMut impl only std::fmt::Write but not std::io::Write. The
|
||||
/// latter trait is required for minidom's
|
||||
/// `Element::write_to_inner()`.
|
||||
struct WriteBytes<'a> {
|
||||
dst: &'a mut BytesMut,
|
||||
}
|
||||
|
||||
impl<'a> WriteBytes<'a> {
|
||||
fn new(dst: &'a mut BytesMut) -> Self {
|
||||
WriteBytes { dst }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> std::io::Write for WriteBytes<'a> {
|
||||
fn write(&mut self, buf: &[u8]) -> std::result::Result<usize, std::io::Error> {
|
||||
self.dst.put_slice(buf);
|
||||
Ok(buf.len())
|
||||
}
|
||||
|
||||
fn flush(&mut self) -> std::result::Result<(), std::io::Error> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
Loading…
Reference in a new issue