chore: Rename User struct to JidContainer

This commit is contained in:
mb 2023-08-14 10:41:36 +02:00 committed by Link Mauve
parent fc23f987cd
commit 2f808f161f

View file

@ -914,14 +914,14 @@ mod tests {
#[cfg(feature = "serde")]
#[derive(Serialize, Deserialize)]
struct User<T> {
struct JidContainer<T> {
jid: T,
}
#[cfg(feature = "serde")]
impl<T> From<T> for User<T> {
fn from(jid: T) -> User<T> {
User { jid }
impl<T> From<T> for JidContainer<T> {
fn from(jid: T) -> JidContainer<T> {
JidContainer { jid }
}
}
@ -933,11 +933,11 @@ mod tests {
#[test]
#[cfg(feature = "serde")]
fn jid_serialize() {
let jid: User<Jid> = Jid::new("node@domain").unwrap().into();
let jid: JidContainer<Jid> = Jid::new("node@domain").unwrap().into();
assert_eq!(BARE_JSON_STR, serde_json::to_string(&jid).unwrap());
let jid: User<BareJid> = BareJid::new("node@domain").unwrap().into();
let jid: JidContainer<BareJid> = BareJid::new("node@domain").unwrap().into();
assert_eq!(BARE_JSON_STR, serde_json::to_string(&jid).unwrap());
let jid: User<FullJid> = FullJid::new("node@domain/resource").unwrap().into();
let jid: JidContainer<FullJid> = FullJid::new("node@domain/resource").unwrap().into();
assert_eq!(FULL_JSON_STR, serde_json::to_string(&jid).unwrap());
}
@ -945,13 +945,13 @@ mod tests {
#[cfg(feature = "serde")]
fn jid_deserialize() {
let jid = Jid::new("node@domain").unwrap();
let deser_jid: User<Jid> = serde_json::from_str(BARE_JSON_STR).unwrap();
let deser_jid: JidContainer<Jid> = serde_json::from_str(BARE_JSON_STR).unwrap();
assert_eq!(jid, deser_jid.jid);
let jid = BareJid::new("node@domain").unwrap();
let deser_jid: User<BareJid> = serde_json::from_str(BARE_JSON_STR).unwrap();
let deser_jid: JidContainer<BareJid> = serde_json::from_str(BARE_JSON_STR).unwrap();
assert_eq!(jid, deser_jid.jid);
let jid = FullJid::new("node@domain/resource").unwrap();
let deser_jid: User<FullJid> = serde_json::from_str(FULL_JSON_STR).unwrap();
let deser_jid: JidContainer<FullJid> = serde_json::from_str(FULL_JSON_STR).unwrap();
assert_eq!(jid, deser_jid.jid);
}
}