xmpp-parsers: Convert ibb to xso
This commit is contained in:
parent
1a7dec6f1e
commit
726801610f
1 changed files with 18 additions and 9 deletions
|
|
@ -27,19 +27,22 @@ Stanza, "stanza", {
|
||||||
Message => "message",
|
Message => "message",
|
||||||
}, Default = Iq);
|
}, Default = Iq);
|
||||||
|
|
||||||
generate_element!(
|
|
||||||
/// Starts an In-Band Bytestream session with the given parameters.
|
/// Starts an In-Band Bytestream session with the given parameters.
|
||||||
Open, "open", IBB,
|
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||||
attributes: [
|
#[xml(namespace = ns::IBB, name = "open")]
|
||||||
|
pub struct Open {
|
||||||
/// Maximum size in bytes for each chunk.
|
/// Maximum size in bytes for each chunk.
|
||||||
block_size: Required<u16> = "block-size",
|
#[xml(attribute(name = "block-size"))]
|
||||||
|
pub block_size: u16,
|
||||||
|
|
||||||
/// The identifier to be used to create a stream.
|
/// The identifier to be used to create a stream.
|
||||||
sid: Required<StreamId> = "sid",
|
#[xml(attribute)]
|
||||||
|
pub sid: StreamId,
|
||||||
|
|
||||||
/// Which stanza type to use to exchange data.
|
/// Which stanza type to use to exchange data.
|
||||||
stanza: Default<Stanza> = "stanza",
|
#[xml(attribute(default))]
|
||||||
]);
|
pub stanza: Stanza,
|
||||||
|
}
|
||||||
|
|
||||||
impl IqSetPayload for Open {}
|
impl IqSetPayload for Open {}
|
||||||
|
|
||||||
|
|
@ -138,7 +141,10 @@ mod tests {
|
||||||
FromElementError::Invalid(Error::Other(string)) => string,
|
FromElementError::Invalid(Error::Other(string)) => string,
|
||||||
_ => panic!(),
|
_ => panic!(),
|
||||||
};
|
};
|
||||||
assert_eq!(message, "Required attribute 'block-size' missing.");
|
assert_eq!(
|
||||||
|
message,
|
||||||
|
"Required attribute field 'block_size' on Open element missing."
|
||||||
|
);
|
||||||
|
|
||||||
let elem: Element = "<open xmlns='http://jabber.org/protocol/ibb' block-size='-5'/>"
|
let elem: Element = "<open xmlns='http://jabber.org/protocol/ibb' block-size='-5'/>"
|
||||||
.parse()
|
.parse()
|
||||||
|
|
@ -162,7 +168,10 @@ mod tests {
|
||||||
FromElementError::Invalid(Error::Other(error)) => error,
|
FromElementError::Invalid(Error::Other(error)) => error,
|
||||||
_ => panic!(),
|
_ => panic!(),
|
||||||
};
|
};
|
||||||
assert_eq!(message, "Required attribute 'sid' missing.");
|
assert_eq!(
|
||||||
|
message,
|
||||||
|
"Required attribute field 'sid' on Open element missing."
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue