From eb0bc1b82fdfc95a6fb8a4f1fea5dca7b1850f84 Mon Sep 17 00:00:00 2001 From: Parker Date: Sat, 15 Jun 2024 09:21:20 -0400 Subject: [PATCH] Changed name to XmppCodec --- tokio-xmpp/examples/echo_server.rs | 4 ++-- tokio-xmpp/src/lib.rs | 2 +- tokio-xmpp/src/stream_start.rs | 4 ++-- tokio-xmpp/src/xmpp_codec.rs | 26 +++++++++++++------------- tokio-xmpp/src/xmpp_stream.rs | 8 ++++---- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/tokio-xmpp/examples/echo_server.rs b/tokio-xmpp/examples/echo_server.rs index 096ede0f..c8036246 100644 --- a/tokio-xmpp/examples/echo_server.rs +++ b/tokio-xmpp/examples/echo_server.rs @@ -2,7 +2,7 @@ use futures::{SinkExt, StreamExt}; use tokio::{self, io, net::TcpSocket}; use tokio_util::codec::Framed; -use tokio_xmpp::XMPPCodec; +use tokio_xmpp::XmppCodec; #[tokio::main] async fn main() -> Result<(), io::Error> { @@ -18,7 +18,7 @@ async fn main() -> Result<(), io::Error> { let (stream, _addr) = listener.accept().await?; // Use the `XMPPCodec` to encode and decode frames - let mut framed = Framed::new(stream, XMPPCodec::new()); + let mut framed = Framed::new(stream, XmppCodec::new()); tokio::spawn(async move { while let Some(packet) = framed.next().await { diff --git a/tokio-xmpp/src/lib.rs b/tokio-xmpp/src/lib.rs index 3d5fd07d..ba2e6048 100644 --- a/tokio-xmpp/src/lib.rs +++ b/tokio-xmpp/src/lib.rs @@ -25,7 +25,7 @@ mod stream_start; #[cfg(feature = "insecure-tcp")] pub mod tcp; mod xmpp_codec; -pub use crate::xmpp_codec::{Packet, XMPPCodec}; +pub use crate::xmpp_codec::{Packet, XmppCodec}; mod event; pub use event::Event; mod client; diff --git a/tokio-xmpp/src/stream_start.rs b/tokio-xmpp/src/stream_start.rs index 4bd3fd28..700f802c 100644 --- a/tokio-xmpp/src/stream_start.rs +++ b/tokio-xmpp/src/stream_start.rs @@ -3,14 +3,14 @@ use tokio::io::{AsyncRead, AsyncWrite}; use tokio_util::codec::Framed; use xmpp_parsers::{ns, Element, Jid}; -use crate::xmpp_codec::{Packet, XMPPCodec}; +use crate::xmpp_codec::{Packet, XmppCodec}; use crate::xmpp_stream::XMPPStream; use crate::{Error, ProtocolError}; /// Sends a ``, then wait for one from the server, and /// construct an XMPPStream. pub async fn start( - mut stream: Framed, + mut stream: Framed, jid: Jid, ns: String, ) -> Result, Error> { diff --git a/tokio-xmpp/src/xmpp_codec.rs b/tokio-xmpp/src/xmpp_codec.rs index baef066f..29123642 100644 --- a/tokio-xmpp/src/xmpp_codec.rs +++ b/tokio-xmpp/src/xmpp_codec.rs @@ -59,7 +59,7 @@ pub enum Packet { } /// Stateful encoder/decoder for a bytestream from/to XMPP `Packet` -pub struct XMPPCodec { +pub struct XmppCodec { /// Outgoing ns: Option, /// Incoming @@ -67,7 +67,7 @@ pub struct XMPPCodec { stanza_builder: TreeBuilder, } -impl XMPPCodec { +impl XmppCodec { /// Constructor pub fn new() -> Self { let stanza_builder = TreeBuilder::new(); @@ -76,7 +76,7 @@ impl XMPPCodec { if log::log_enabled!(log::Level::Debug) && PS.get().is_none() { init_syntect(); } - XMPPCodec { + XmppCodec { ns: None, driver, stanza_builder, @@ -84,13 +84,13 @@ impl XMPPCodec { } } -impl Default for XMPPCodec { +impl Default for XmppCodec { fn default() -> Self { Self::new() } } -impl Decoder for XMPPCodec { +impl Decoder for XmppCodec { type Item = Packet; type Error = Error; @@ -149,7 +149,7 @@ impl Decoder for XMPPCodec { } } -impl Encoder for XMPPCodec { +impl Encoder for XmppCodec { type Error = Error; fn encode(&mut self, item: Packet, dst: &mut BytesMut) -> Result<(), Self::Error> { @@ -253,7 +253,7 @@ mod tests { #[test] fn test_stream_start() { - let mut c = XMPPCodec::new(); + let mut c = XmppCodec::new(); let mut b = BytesMut::with_capacity(1024); b.put_slice(b""); let r = c.decode(&mut b); @@ -265,7 +265,7 @@ mod tests { #[test] fn test_stream_end() { - let mut c = XMPPCodec::new(); + let mut c = XmppCodec::new(); let mut b = BytesMut::with_capacity(1024); b.put_slice(b""); let r = c.decode(&mut b); @@ -283,7 +283,7 @@ mod tests { #[test] fn test_truncated_stanza() { - let mut c = XMPPCodec::new(); + let mut c = XmppCodec::new(); let mut b = BytesMut::with_capacity(1024); b.put_slice(b""); let r = c.decode(&mut b); @@ -309,7 +309,7 @@ mod tests { #[test] fn test_truncated_utf8() { - let mut c = XMPPCodec::new(); + let mut c = XmppCodec::new(); let mut b = BytesMut::with_capacity(1024); b.put_slice(b""); let r = c.decode(&mut b); @@ -336,7 +336,7 @@ mod tests { /// test case for https://gitlab.com/xmpp-rs/tokio-xmpp/issues/3 #[test] fn test_atrribute_prefix() { - let mut c = XMPPCodec::new(); + let mut c = XmppCodec::new(); let mut b = BytesMut::with_capacity(1024); b.put_slice(b""); let r = c.decode(&mut b); @@ -363,7 +363,7 @@ mod tests { use futures::{executor::block_on, sink::SinkExt}; use std::io::Cursor; use tokio_util::codec::FramedWrite; - let mut framed = FramedWrite::new(Cursor::new(vec![]), XMPPCodec::new()); + let mut framed = FramedWrite::new(Cursor::new(vec![]), XmppCodec::new()); let mut text = "".to_owned(); for _ in 0..2usize.pow(15) { text = text + "A"; @@ -388,7 +388,7 @@ mod tests { #[test] fn test_cut_out_stanza() { - let mut c = XMPPCodec::new(); + let mut c = XmppCodec::new(); let mut b = BytesMut::with_capacity(1024); b.put_slice(b""); let r = c.decode(&mut b); diff --git a/tokio-xmpp/src/xmpp_stream.rs b/tokio-xmpp/src/xmpp_stream.rs index c1f82bad..57bd8e52 100644 --- a/tokio-xmpp/src/xmpp_stream.rs +++ b/tokio-xmpp/src/xmpp_stream.rs @@ -11,7 +11,7 @@ use xmpp_parsers::{Element, Jid}; use crate::stream_features::StreamFeatures; use crate::stream_start; -use crate::xmpp_codec::{Packet, XMPPCodec}; +use crate::xmpp_codec::{Packet, XmppCodec}; use crate::Error; fn make_id() -> String { @@ -40,7 +40,7 @@ pub struct XMPPStream { /// The local Jabber-Id pub jid: Jid, /// Codec instance - pub stream: Framed, + pub stream: Framed, /// `` for XMPP version 1.0 pub stream_features: StreamFeatures, /// Root namespace @@ -56,7 +56,7 @@ impl XMPPStream { /// Constructor pub fn new( jid: Jid, - stream: Framed, + stream: Framed, ns: String, id: String, stream_features: Element, @@ -72,7 +72,7 @@ impl XMPPStream { /// Send a `` start tag pub async fn start(stream: S, jid: Jid, ns: String) -> Result { - let xmpp_stream = Framed::new(stream, XMPPCodec::new()); + let xmpp_stream = Framed::new(stream, XmppCodec::new()); stream_start::start(xmpp_stream, jid, ns).await }