jingle_ft: Use jingle’s ContentId type to identify content names.

This commit is contained in:
Emmanuel Gil Peyrot 2017-10-31 16:11:09 +00:00
parent 0200ced3e5
commit db9ef3ef30

View file

@ -10,7 +10,7 @@ use std::collections::BTreeMap;
use std::str::FromStr; use std::str::FromStr;
use hashes::Hash; use hashes::Hash;
use jingle::Creator; use jingle::{Creator, ContentId};
use minidom::{Element, IntoElements, IntoAttributeValue, ElementEmitter}; use minidom::{Element, IntoElements, IntoAttributeValue, ElementEmitter};
use chrono::{DateTime, FixedOffset}; use chrono::{DateTime, FixedOffset};
@ -61,14 +61,14 @@ pub struct Description {
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct Checksum { pub struct Checksum {
pub name: String, pub name: ContentId,
pub creator: Creator, pub creator: Creator,
pub file: File, pub file: File,
} }
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct Received { pub struct Received {
pub name: String, pub name: ContentId,
pub creator: Creator, pub creator: Creator,
} }
@ -337,11 +337,11 @@ mod tests {
fn test_received() { fn test_received() {
let elem: Element = "<received xmlns='urn:xmpp:jingle:apps:file-transfer:5' name='coucou' creator='initiator'/>".parse().unwrap(); let elem: Element = "<received xmlns='urn:xmpp:jingle:apps:file-transfer:5' name='coucou' creator='initiator'/>".parse().unwrap();
let received = Received::try_from(elem).unwrap(); let received = Received::try_from(elem).unwrap();
assert_eq!(received.name, String::from("coucou")); assert_eq!(received.name, ContentId(String::from("coucou")));
assert_eq!(received.creator, Creator::Initiator); assert_eq!(received.creator, Creator::Initiator);
let elem2 = Element::from(received.clone()); let elem2 = Element::from(received.clone());
let received2 = Received::try_from(elem2).unwrap(); let received2 = Received::try_from(elem2).unwrap();
assert_eq!(received2.name, String::from("coucou")); assert_eq!(received2.name, ContentId(String::from("coucou")));
assert_eq!(received2.creator, Creator::Initiator); assert_eq!(received2.creator, Creator::Initiator);
let elem: Element = "<received xmlns='urn:xmpp:jingle:apps:file-transfer:5' name='coucou' creator='initiator'><coucou/></received>".parse().unwrap(); let elem: Element = "<received xmlns='urn:xmpp:jingle:apps:file-transfer:5' name='coucou' creator='initiator'><coucou/></received>".parse().unwrap();