diff --git a/crates/projection-xmpp/src/proto.rs b/crates/projection-xmpp/src/proto.rs index 8b16ef0..0b157a6 100644 --- a/crates/projection-xmpp/src/proto.rs +++ b/crates/projection-xmpp/src/proto.rs @@ -25,7 +25,7 @@ impl FromXml for IqClientBody { type P = impl Parser>; fn parse() -> Self::P { - |(namespace, event): (ResolveResult<'static>, &'static Event<'static>)| -> Result { + |(mut namespace, mut event): (ResolveResult<'static>, &'static Event<'static>)| -> Result { let bytes = match event { Event::Start(bytes) => bytes, Event::Empty(bytes) => bytes, @@ -59,7 +59,7 @@ impl FromXml for ClientPacket { type P = impl Parser>; fn parse() -> Self::P { - |(namespace, event): (ResolveResult<'static>, &'static Event<'static>)| -> Result { + |(mut namespace, mut event): (ResolveResult<'static>, &'static Event<'static>)| -> Result { match event { Event::Start(bytes) | Event::Empty(bytes) => { let name = bytes.name(); diff --git a/crates/proto-xmpp/src/bind.rs b/crates/proto-xmpp/src/bind.rs index dc0d1ce..d27a00e 100644 --- a/crates/proto-xmpp/src/bind.rs +++ b/crates/proto-xmpp/src/bind.rs @@ -82,7 +82,7 @@ impl FromXml for BindRequest { type P = impl Parser>; fn parse() -> Self::P { - |(namespace, event): (ResolveResult<'static>, &'static Event<'static>)| -> Result { + |(mut namespace, mut event): (ResolveResult<'static>, &'static Event<'static>)| -> Result { let mut resource: Option = None; let Event::Start(bytes) = event else { return Err(anyhow!("Unexpected XML event: {event:?}")); @@ -97,15 +97,15 @@ impl FromXml for BindRequest { return Err(anyhow!("Incorrect namespace")); } loop { - let (namespace, event) = yield; + (namespace, event) = yield; match event { Event::Start(bytes) if bytes.name().0 == b"resource" => { - let (namespace, event) = yield; + (namespace, event) = yield; let Event::Text(text) = event else { return Err(anyhow!("Unexpected XML event: {event:?}")); }; resource = Some(std::str::from_utf8(&*text)?.into()); - let (namespace, event) = yield; + (namespace, event) = yield; let Event::End(bytes) = event else { return Err(anyhow!("Unexpected XML event: {event:?}")); }; diff --git a/crates/proto-xmpp/src/client.rs b/crates/proto-xmpp/src/client.rs index 85b3979..05807bd 100644 --- a/crates/proto-xmpp/src/client.rs +++ b/crates/proto-xmpp/src/client.rs @@ -378,7 +378,7 @@ impl Parser for IqParser { } }, IqParserInner::Final(state) => { - if let Event::End(ref bytes) = event { + if let Event::End(_) = event { let id = fail_fast!(state.id.ok_or_else(|| ffail!("No id provided"))); let r#type = fail_fast!(state.r#type.ok_or_else(|| ffail!("No type provided"))); let body = fail_fast!(state.body.ok_or_else(|| ffail!("No body provided"))); @@ -528,7 +528,7 @@ impl FromXml for Presence { type P = impl Parser>>; fn parse() -> Self::P { - |(namespace, event): (ResolveResult<'static>, &'static Event<'static>)| -> Result { + |(mut namespace, mut event): (ResolveResult<'static>, &'static Event<'static>)| -> Result { let (bytes, end) = match event { Event::Start(bytes) => (bytes, false), Event::Empty(bytes) => (bytes, true), @@ -557,37 +557,37 @@ impl FromXml for Presence { return Ok(p); } loop { - let (namespace, event) = yield; + (namespace, event) = yield; match event { Event::Start(bytes) => match bytes.name().0 { b"show" => { - let (_, event) = yield; + (namespace, event) = yield; let Event::Text(bytes) = event else { return Err(ffail!("Unexpected XML event: {event:?}")); }; let i = PresenceShow::from_str(bytes)?; p.show = Some(i); - let (_, event) = yield; + (namespace, event) = yield; let Event::End(_) = event else { return Err(ffail!("Unexpected XML event: {event:?}")); }; } b"status" => { - let (_, event) = yield; + (namespace, event) = yield; let Event::Text(bytes) = event else { return Err(ffail!("Unexpected XML event: {event:?}")); }; let s = std::str::from_utf8(bytes)?; p.status.push(s.to_string()); - let (_, event) = yield; + (namespace, event) = yield; let Event::End(_) = event else { return Err(ffail!("Unexpected XML event: {event:?}")); }; } b"priority" => { - let (_, event) = yield; + (namespace, event) = yield; let Event::Text(bytes) = event else { return Err(ffail!("Unexpected XML event: {event:?}")); }; @@ -595,7 +595,7 @@ impl FromXml for Presence { let i = s.parse()?; p.priority = Some(PresencePriority(i)); - let (_, event) = yield; + (namespace, event) = yield; let Event::End(_) = event else { return Err(ffail!("Unexpected XML event: {event:?}")); }; diff --git a/crates/proto-xmpp/src/disco.rs b/crates/proto-xmpp/src/disco.rs index af7771b..bea4611 100644 --- a/crates/proto-xmpp/src/disco.rs +++ b/crates/proto-xmpp/src/disco.rs @@ -21,7 +21,7 @@ impl FromXml for InfoQuery { type P = impl Parser>; fn parse() -> Self::P { - |(namespace, event): (ResolveResult<'static>, &'static Event<'static>)| -> Result { + |(mut namespace, mut event): (ResolveResult<'static>, &'static Event<'static>)| -> Result { let mut node = None; let mut identity = vec![]; let mut feature = vec![]; @@ -48,7 +48,7 @@ impl FromXml for InfoQuery { }); } loop { - let (namespace, event) = yield; + (namespace, event) = yield; let bytes = match event { Event::Start(bytes) => bytes, Event::Empty(bytes) => bytes, @@ -141,7 +141,7 @@ impl FromXml for Identity { type P = impl Parser>; fn parse() -> Self::P { - |(namespace, event): (ResolveResult<'static>, &'static Event<'static>)| -> Result { + |(mut namespace, mut event): (ResolveResult<'static>, &'static Event<'static>)| -> Result { let mut category = None; let mut name = None; let mut r#type = None; @@ -179,8 +179,8 @@ impl FromXml for Identity { return Ok(item); } - let (namespace, event) = yield; - let Event::End(bytes) = event else { + (namespace, event) = yield; + let Event::End(_) = event else { return Err(ffail!("Unexpected XML event: {event:?}")); }; Ok(item) @@ -209,7 +209,7 @@ impl FromXml for Feature { type P = impl Parser>; fn parse() -> Self::P { - |(namespace, event): (ResolveResult<'static>, &'static Event<'static>)| -> Result { + |(mut namespace, mut event): (ResolveResult<'static>, &'static Event<'static>)| -> Result { let mut var = None; let (bytes, end) = match event { Event::Start(bytes) => (bytes, false), @@ -234,8 +234,8 @@ impl FromXml for Feature { return Ok(item); } - let (namespace, event) = yield; - let Event::End(bytes) = event else { + (namespace, event) = yield; + let Event::End(_) = event else { return Err(ffail!("Unexpected XML event: {event:?}")); }; Ok(item) @@ -258,9 +258,9 @@ impl FromXml for ItemQuery { type P = impl Parser>; fn parse() -> Self::P { - |(namespace, event): (ResolveResult<'static>, &'static Event<'static>)| -> Result { + |(mut namespace, mut event): (ResolveResult<'static>, &'static Event<'static>)| -> Result { let mut item = vec![]; - let (bytes, end) = match event { + let (_, end) = match event { Event::Start(bytes) => (bytes, false), Event::Empty(bytes) => (bytes, true), _ => return Err(ffail!("Unexpected XML event: {event:?}")), @@ -269,7 +269,7 @@ impl FromXml for ItemQuery { return Ok(ItemQuery { item }); } loop { - let (namespace, event) = yield; + (namespace, event) = yield; let bytes = match event { Event::Start(bytes) => bytes, Event::Empty(bytes) => bytes, @@ -296,7 +296,7 @@ impl FromXmlTag for ItemQuery { impl ToXml for ItemQuery { fn serialize(&self, events: &mut Vec>) { - let mut bytes = BytesStart::new(format!(r#"query xmlns="{}""#, XMLNS_ITEM)); + let bytes = BytesStart::new(format!(r#"query xmlns="{}""#, XMLNS_ITEM)); let empty = self.item.is_empty(); if empty { events.push(Event::Empty(bytes)); @@ -342,7 +342,7 @@ impl FromXml for Item { type P = impl Parser>; fn parse() -> Self::P { - |(namespace, event): (ResolveResult<'static>, &'static Event<'static>)| -> Result { + |(_, mut event): (ResolveResult<'static>, &'static Event<'static>)| -> Result { let mut jid = None; let mut name = None; let mut node = None; @@ -378,8 +378,8 @@ impl FromXml for Item { return Ok(item); } - let (namespace, event) = yield; - let Event::End(bytes) = event else { + (_, event) = yield; + let Event::End(_) = event else { return Err(ffail!("Unexpected XML event: {event:?}")); }; Ok(item) diff --git a/crates/proto-xmpp/src/muc/mod.rs b/crates/proto-xmpp/src/muc/mod.rs index 0a6e702..f357dd0 100644 --- a/crates/proto-xmpp/src/muc/mod.rs +++ b/crates/proto-xmpp/src/muc/mod.rs @@ -19,7 +19,7 @@ impl FromXml for History { type P = impl Parser>; fn parse() -> Self::P { - |(namespace, event): (ResolveResult<'static>, &'static Event<'static>)| -> Result { + |(mut namespace, mut event): (ResolveResult<'static>, &'static Event<'static>)| -> Result { let mut history = History::default(); let (bytes, end) = match event { Event::Start(bytes) if bytes.name().0 == Self::NAME.as_bytes() => (bytes, false), @@ -51,7 +51,7 @@ impl FromXml for History { return Ok(history); } - let (namespace, event) = yield; + (namespace, event) = yield; let Event::End(bytes) = event else { return Err(anyhow!("Unexpected XML event: {event:?}")); }; @@ -73,17 +73,17 @@ impl FromXml for Password { type P = impl Parser>; fn parse() -> Self::P { - |(namespace, event): (ResolveResult<'static>, &'static Event<'static>)| -> Result { + |(mut namespace, mut event): (ResolveResult<'static>, &'static Event<'static>)| -> Result { let bytes = match event { Event::Start(bytes) if bytes.name().0 == Self::NAME.as_bytes() => bytes, _ => return Err(anyhow!("Unexpected XML event: {event:?}")), }; - let (namespace, event) = yield; + (namespace, event) = yield; let Event::Text(bytes) = event else { return Err(anyhow!("Unexpected XML event: {event:?}")); }; let s = std::str::from_utf8(bytes)?.to_string(); - let (namespace, event) = yield; + (namespace, event) = yield; let Event::End(bytes) = event else { return Err(anyhow!("Unexpected XML event: {event:?}")); }; @@ -108,7 +108,7 @@ impl FromXml for X { type P = impl Parser>; fn parse() -> Self::P { - |(namespace, event): (ResolveResult<'static>, &'static Event<'static>)| -> Result { + |(mut namespace, mut event): (ResolveResult<'static>, &'static Event<'static>)| -> Result { let mut res = X::default(); let (_, end) = match event { Event::Start(bytes) => (bytes, false), @@ -120,7 +120,7 @@ impl FromXml for X { } loop { - let (namespace, event) = yield; + (namespace, event) = yield; let bytes = match event { Event::Start(bytes) => bytes, Event::Empty(bytes) => bytes, diff --git a/crates/proto-xmpp/src/xml/mod.rs b/crates/proto-xmpp/src/xml/mod.rs index 1919ff2..b928fa0 100644 --- a/crates/proto-xmpp/src/xml/mod.rs +++ b/crates/proto-xmpp/src/xml/mod.rs @@ -89,8 +89,8 @@ macro_rules! delegate_parsing { Continuation::Final(Ok(res)) => break Ok(res.into()), Continuation::Final(Err(err)) => break Err(err), Continuation::Continue(p) => { - let (namespace, event) = yield; - parser = p.consume(namespace, event); + ($namespace, $event) = yield; + parser = p.consume($namespace, $event); } } } diff --git a/src/main.rs b/src/main.rs index d72055b..9b73b1f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -109,7 +109,7 @@ fn set_up_logging(tracing_config: &Option) -> Result<()> { let targets = { use std::{env, str::FromStr}; - use tracing_subscriber::{filter::Targets, layer::SubscriberExt}; + use tracing_subscriber::filter::Targets; match env::var("RUST_LOG") { Ok(var) => Targets::from_str(&var) .map_err(|e| {