diff --git a/ChangeLog b/ChangeLog index a855cb7..ea8f73c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,7 @@ DATE Emmanuel Gil Peyrot * Breaking changes: - Stop reexporting TryFrom and TryInto, they are available in std::convert nowadays. + - Bind has been split into BindQuery and BindResponse. * Improvements: - New DOAP file for a machine-readable description of the features. diff --git a/src/bind.rs b/src/bind.rs index 35d2204..357a732 100644 --- a/src/bind.rs +++ b/src/bind.rs @@ -17,7 +17,7 @@ use std::convert::TryFrom; /// /// See https://xmpp.org/rfcs/rfc6120.html#bind #[derive(Debug, Clone, PartialEq)] -pub struct BindRequest { +pub struct BindQuery { /// Requests this resource, the server may associate another one though. /// /// If this is None, we request no particular resource, and a random one @@ -25,19 +25,19 @@ pub struct BindRequest { resource: Option, } -impl BindRequest { +impl BindQuery { /// Creates a resource binding request. - pub fn new(resource: Option) -> BindRequest { - BindRequest { resource } + pub fn new(resource: Option) -> BindQuery { + BindQuery { resource } } } -impl IqSetPayload for BindRequest {} +impl IqSetPayload for BindQuery {} -impl TryFrom for BindRequest { +impl TryFrom for BindQuery { type Error = Error; - fn try_from(elem: Element) -> Result { + fn try_from(elem: Element) -> Result { check_self!(elem, "bind", BIND); check_no_attributes!(elem, "bind"); @@ -55,12 +55,12 @@ impl TryFrom for BindRequest { } } - Ok(BindRequest { resource }) + Ok(BindQuery { resource }) } } -impl From for Element { - fn from(bind: BindRequest) -> Element { +impl From for Element { + fn from(bind: BindQuery) -> Element { Element::builder("bind") .ns(ns::BIND) .append(match bind.resource { @@ -129,14 +129,14 @@ mod tests { #[cfg(target_pointer_width = "32")] #[test] fn test_size() { - assert_size!(BindRequest, 12); + assert_size!(BindQuery, 12); assert_size!(BindResponse, 36); } #[cfg(target_pointer_width = "64")] #[test] fn test_size() { - assert_size!(BindRequest, 24); + assert_size!(BindQuery, 24); assert_size!(BindResponse, 72); } @@ -145,13 +145,13 @@ mod tests { let elem: Element = "" .parse() .unwrap(); - let bind = BindRequest::try_from(elem).unwrap(); + let bind = BindQuery::try_from(elem).unwrap(); assert_eq!(bind.resource, None); let elem: Element = "Hello™" .parse() .unwrap(); - let bind = BindRequest::try_from(elem).unwrap(); + let bind = BindQuery::try_from(elem).unwrap(); // FIXME: “™” should be resourceprep’d into “TM” here… //assert_eq!(bind.resource.unwrap(), "HelloTM"); assert_eq!(bind.resource.unwrap(), "Hello™"); @@ -169,7 +169,7 @@ mod tests { let elem: Element = "resource" .parse() .unwrap(); - let error = BindRequest::try_from(elem).unwrap_err(); + let error = BindQuery::try_from(elem).unwrap_err(); let message = match error { Error::ParseError(string) => string, _ => panic!(), @@ -179,7 +179,7 @@ mod tests { let elem: Element = "resource" .parse() .unwrap(); - let error = BindRequest::try_from(elem).unwrap_err(); + let error = BindQuery::try_from(elem).unwrap_err(); let message = match error { Error::ParseError(string) => string, _ => panic!(),