From 6f1fc7b009ef22083790d1c786dbd633d8f41ab4 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Fri, 6 Sep 2019 11:45:04 +0200 Subject: [PATCH] bind: Easily convert BindResponse into FullJid or Jid. --- src/bind.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/bind.rs b/src/bind.rs index 17e1e124..22beccd1 100644 --- a/src/bind.rs +++ b/src/bind.rs @@ -7,7 +7,7 @@ use crate::util::error::Error; use crate::iq::{IqResultPayload, IqSetPayload}; use crate::ns; -use jid::FullJid; +use jid::{FullJid, Jid}; use minidom::Element; use std::str::FromStr; use std::convert::TryFrom; @@ -85,6 +85,18 @@ pub struct BindResponse { impl IqResultPayload for BindResponse {} +impl From for FullJid { + fn from(bind: BindResponse) -> FullJid { + bind.jid + } +} + +impl From for Jid { + fn from(bind: BindResponse) -> Jid { + Jid::Full(bind.jid) + } +} + impl TryFrom for BindResponse { type Error = Error;