mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
bind: Document the split in ChangeLog.
This commit is contained in:
parent
08fa36d186
commit
08c3cb8c6f
2 changed files with 17 additions and 16 deletions
|
@ -6,6 +6,7 @@ DATE Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
|
||||||
* Breaking changes:
|
* Breaking changes:
|
||||||
- Stop reexporting TryFrom and TryInto, they are available in
|
- Stop reexporting TryFrom and TryInto, they are available in
|
||||||
std::convert nowadays.
|
std::convert nowadays.
|
||||||
|
- Bind has been split into BindQuery and BindResponse.
|
||||||
* Improvements:
|
* Improvements:
|
||||||
- New DOAP file for a machine-readable description of the features.
|
- New DOAP file for a machine-readable description of the features.
|
||||||
|
|
||||||
|
|
32
src/bind.rs
32
src/bind.rs
|
@ -17,7 +17,7 @@ use std::convert::TryFrom;
|
||||||
///
|
///
|
||||||
/// See https://xmpp.org/rfcs/rfc6120.html#bind
|
/// See https://xmpp.org/rfcs/rfc6120.html#bind
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub struct BindRequest {
|
pub struct BindQuery {
|
||||||
/// Requests this resource, the server may associate another one though.
|
/// Requests this resource, the server may associate another one though.
|
||||||
///
|
///
|
||||||
/// If this is None, we request no particular resource, and a random one
|
/// If this is None, we request no particular resource, and a random one
|
||||||
|
@ -25,19 +25,19 @@ pub struct BindRequest {
|
||||||
resource: Option<String>,
|
resource: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BindRequest {
|
impl BindQuery {
|
||||||
/// Creates a resource binding request.
|
/// Creates a resource binding request.
|
||||||
pub fn new(resource: Option<String>) -> BindRequest {
|
pub fn new(resource: Option<String>) -> BindQuery {
|
||||||
BindRequest { resource }
|
BindQuery { resource }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IqSetPayload for BindRequest {}
|
impl IqSetPayload for BindQuery {}
|
||||||
|
|
||||||
impl TryFrom<Element> for BindRequest {
|
impl TryFrom<Element> for BindQuery {
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
|
|
||||||
fn try_from(elem: Element) -> Result<BindRequest, Error> {
|
fn try_from(elem: Element) -> Result<BindQuery, Error> {
|
||||||
check_self!(elem, "bind", BIND);
|
check_self!(elem, "bind", BIND);
|
||||||
check_no_attributes!(elem, "bind");
|
check_no_attributes!(elem, "bind");
|
||||||
|
|
||||||
|
@ -55,12 +55,12 @@ impl TryFrom<Element> for BindRequest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(BindRequest { resource })
|
Ok(BindQuery { resource })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<BindRequest> for Element {
|
impl From<BindQuery> for Element {
|
||||||
fn from(bind: BindRequest) -> Element {
|
fn from(bind: BindQuery) -> Element {
|
||||||
Element::builder("bind")
|
Element::builder("bind")
|
||||||
.ns(ns::BIND)
|
.ns(ns::BIND)
|
||||||
.append(match bind.resource {
|
.append(match bind.resource {
|
||||||
|
@ -129,14 +129,14 @@ mod tests {
|
||||||
#[cfg(target_pointer_width = "32")]
|
#[cfg(target_pointer_width = "32")]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_size() {
|
fn test_size() {
|
||||||
assert_size!(BindRequest, 12);
|
assert_size!(BindQuery, 12);
|
||||||
assert_size!(BindResponse, 36);
|
assert_size!(BindResponse, 36);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_pointer_width = "64")]
|
#[cfg(target_pointer_width = "64")]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_size() {
|
fn test_size() {
|
||||||
assert_size!(BindRequest, 24);
|
assert_size!(BindQuery, 24);
|
||||||
assert_size!(BindResponse, 72);
|
assert_size!(BindResponse, 72);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,13 +145,13 @@ mod tests {
|
||||||
let elem: Element = "<bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/>"
|
let elem: Element = "<bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/>"
|
||||||
.parse()
|
.parse()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let bind = BindRequest::try_from(elem).unwrap();
|
let bind = BindQuery::try_from(elem).unwrap();
|
||||||
assert_eq!(bind.resource, None);
|
assert_eq!(bind.resource, None);
|
||||||
|
|
||||||
let elem: Element = "<bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><resource>Hello™</resource></bind>"
|
let elem: Element = "<bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><resource>Hello™</resource></bind>"
|
||||||
.parse()
|
.parse()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let bind = BindRequest::try_from(elem).unwrap();
|
let bind = BindQuery::try_from(elem).unwrap();
|
||||||
// FIXME: “™” should be resourceprep’d into “TM” here…
|
// FIXME: “™” should be resourceprep’d into “TM” here…
|
||||||
//assert_eq!(bind.resource.unwrap(), "HelloTM");
|
//assert_eq!(bind.resource.unwrap(), "HelloTM");
|
||||||
assert_eq!(bind.resource.unwrap(), "Hello™");
|
assert_eq!(bind.resource.unwrap(), "Hello™");
|
||||||
|
@ -169,7 +169,7 @@ mod tests {
|
||||||
let elem: Element = "<bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><resource attr='coucou'>resource</resource></bind>"
|
let elem: Element = "<bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><resource attr='coucou'>resource</resource></bind>"
|
||||||
.parse()
|
.parse()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let error = BindRequest::try_from(elem).unwrap_err();
|
let error = BindQuery::try_from(elem).unwrap_err();
|
||||||
let message = match error {
|
let message = match error {
|
||||||
Error::ParseError(string) => string,
|
Error::ParseError(string) => string,
|
||||||
_ => panic!(),
|
_ => panic!(),
|
||||||
|
@ -179,7 +179,7 @@ mod tests {
|
||||||
let elem: Element = "<bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><resource><hello-world/>resource</resource></bind>"
|
let elem: Element = "<bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><resource><hello-world/>resource</resource></bind>"
|
||||||
.parse()
|
.parse()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let error = BindRequest::try_from(elem).unwrap_err();
|
let error = BindQuery::try_from(elem).unwrap_err();
|
||||||
let message = match error {
|
let message = match error {
|
||||||
Error::ParseError(string) => string,
|
Error::ParseError(string) => string,
|
||||||
_ => panic!(),
|
_ => panic!(),
|
||||||
|
|
Loading…
Reference in a new issue