stanzastream: handle malformed stanzas more gracefully
This introduces the FallibleStreamElement type which, instead of failing parsing altogether, captures certain types of parse errors and allows the user (in this case, the stanzastream) to react to these errors appropriately. This allows us to drop invalid stanzas (e.g. with malformed values in strictly-checked fields) instead of failing the entire stream. Fixes #172.
This commit is contained in:
parent
bda08407b0
commit
cc92d113fa
11 changed files with 401 additions and 31 deletions
|
|
@ -55,7 +55,11 @@ pub async fn auth<S: AsyncBufRead + AsyncWrite + Unpin>(
|
|||
.await?;
|
||||
|
||||
loop {
|
||||
match stream.next().await {
|
||||
match stream
|
||||
.next()
|
||||
.await
|
||||
.map(|v| v.map(|v| v.into_read_error()).flatten())
|
||||
{
|
||||
Some(Ok(XmppStreamElement::Sasl(sasl))) => match sasl {
|
||||
Nonza::Challenge(challenge) => {
|
||||
let response = mechanism
|
||||
|
|
|
|||
Loading…
Reference in a new issue