Merge branch 'minidom' into 'master'
Optionally implement minidom::IntoAttributeValue See merge request !6
This commit is contained in:
commit
0ed1a00c17
2 changed files with 22 additions and 0 deletions
|
@ -14,3 +14,4 @@ license = "LGPL-3.0+"
|
||||||
gitlab = { repository = "lumi/jid-rs" }
|
gitlab = { repository = "lumi/jid-rs" }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
minidom = { version = "0.4.4", optional = true }
|
||||||
|
|
21
src/lib.rs
21
src/lib.rs
|
@ -359,6 +359,19 @@ impl Jid {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "minidom")]
|
||||||
|
extern crate minidom;
|
||||||
|
|
||||||
|
#[cfg(feature = "minidom")]
|
||||||
|
use minidom::IntoAttributeValue;
|
||||||
|
|
||||||
|
#[cfg(feature = "minidom")]
|
||||||
|
impl IntoAttributeValue for Jid {
|
||||||
|
fn into_attribute_value(self) -> Option<String> {
|
||||||
|
Some(String::from(self))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
@ -380,4 +393,12 @@ mod tests {
|
||||||
fn serialise() {
|
fn serialise() {
|
||||||
assert_eq!(String::from(Jid::full("a", "b", "c")), String::from("a@b/c"));
|
assert_eq!(String::from(Jid::full("a", "b", "c")), String::from("a@b/c"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "minidom")]
|
||||||
|
#[test]
|
||||||
|
fn minidom() {
|
||||||
|
let elem: minidom::Element = "<message from='a@b/c'/>".parse().unwrap();
|
||||||
|
let to: Jid = elem.attr("from").unwrap().parse().unwrap();
|
||||||
|
assert_eq!(to, Jid::full("a", "b", "c"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue