From 71d732353444855251f2b6c6082c7fd2fcbad21c Mon Sep 17 00:00:00 2001 From: Nikita Vilunov Date: Tue, 21 Mar 2023 01:17:48 +0100 Subject: [PATCH] remove unused struct --- src/protos/xmpp/stream.rs | 56 --------------------------------------- 1 file changed, 56 deletions(-) diff --git a/src/protos/xmpp/stream.rs b/src/protos/xmpp/stream.rs index 71698de..fd62af2 100644 --- a/src/protos/xmpp/stream.rs +++ b/src/protos/xmpp/stream.rs @@ -162,44 +162,8 @@ impl Features { } } -#[derive(PartialEq, Eq, Debug)] -pub enum FromClient { - Message(Message), -} -impl FromClient { - pub async fn parse( - reader: &mut NsReader, - buf: &mut Vec, - ) -> Result { - let incoming = skip_text!(reader, buf); - let start = if let Event::Start(ref bytes) = incoming { - bytes - } else { - return Err(ffail!("Unexpected XML event: {incoming:?}")); - }; - let (ns, name) = reader.resolve_element(start.name()); - if name.as_ref() == b"message" { - let mut parser = Message::parse().consume(ns, &incoming); - let result = loop { - match parser { - Continuation::Final(res) => break res, - Continuation::Continue(next) => { - let (ns, event) = reader.read_resolved_event_into_async(buf).await.unwrap(); - parser = next.consume(ns, &event); - } - } - }?; - Ok(FromClient::Message(result)) - } else { - Err(ffail!("Unknown XML tag: {name:?}")) - } - } -} - #[cfg(test)] mod test { - use crate::protos::xmpp::client::MessageType; - use super::*; #[tokio::test] @@ -233,24 +197,4 @@ mod test { input.write_xml(&mut writer).await.unwrap(); assert_eq!(std::str::from_utf8(&output).unwrap(), expected); } - - #[tokio::test] - async fn client_message() { - let input = r#"daabbb"#; - let mut reader = NsReader::from_reader(input.as_bytes()); - let mut buf = vec![]; - let res = FromClient::parse(&mut reader, &mut buf).await.unwrap(); - assert_eq!( - res, - FromClient::Message(Message { - from: None, - id: Some("aacea".to_string()), - r#type: MessageType::Chat, - to: Some("nikita@vlnv.dev".to_string()), - lang: None, - subject: Some("daa".to_string()), - body: "bbb".to_string(), - }) - ) - } }