forked from lavina/lavina
1
0
Fork 0

use macro in muc parsing

This commit is contained in:
Nikita Vilunov 2023-03-27 23:47:14 +02:00
parent 7b2bfae147
commit 63704d6010
1 changed files with 2 additions and 22 deletions

View File

@ -124,30 +124,10 @@ impl FromXml for X {
_ => return Err(ffail!("Unexpected XML event: {event:?}")), _ => return Err(ffail!("Unexpected XML event: {event:?}")),
}; };
if bytes.name().0 == Password::NAME.as_bytes() { if bytes.name().0 == Password::NAME.as_bytes() {
let mut parser = Password::parse().consume(namespace, event); let password = delegate_parsing!(Password, namespace, event)?;
let password = loop {
match parser {
Continuation::Final(Ok(res)) => break Ok(res),
Continuation::Final(Err(err)) => break Err(err),
Continuation::Continue(p) => {
let (namespace, event) = yield;
parser = p.consume(namespace, event);
}
}
}?;
res.password = Some(password); res.password = Some(password);
} else if bytes.name().0 == History::NAME.as_bytes() { } else if bytes.name().0 == History::NAME.as_bytes() {
let mut parser = History::parse().consume(namespace, event); let history = delegate_parsing!(History, namespace, event)?;
let history = loop {
match parser {
Continuation::Final(Ok(res)) => break Ok(res),
Continuation::Final(Err(err)) => break Err(err),
Continuation::Continue(p) => {
let (namespace, event) = yield;
parser = p.consume(namespace, event);
}
}
}?;
res.history = Some(history); res.history = Some(history);
} else { } else {
return Err(ffail!("Unexpected XML event: {event:?}")); return Err(ffail!("Unexpected XML event: {event:?}"));