bind: Easily convert BindResponse into FullJid or Jid.

This commit is contained in:
Emmanuel Gil Peyrot 2019-09-06 11:45:04 +02:00
parent a1ae45add8
commit 6f1fc7b009

View file

@ -7,7 +7,7 @@
use crate::util::error::Error; use crate::util::error::Error;
use crate::iq::{IqResultPayload, IqSetPayload}; use crate::iq::{IqResultPayload, IqSetPayload};
use crate::ns; use crate::ns;
use jid::FullJid; use jid::{FullJid, Jid};
use minidom::Element; use minidom::Element;
use std::str::FromStr; use std::str::FromStr;
use std::convert::TryFrom; use std::convert::TryFrom;
@ -85,6 +85,18 @@ pub struct BindResponse {
impl IqResultPayload for BindResponse {} impl IqResultPayload for BindResponse {}
impl From<BindResponse> for FullJid {
fn from(bind: BindResponse) -> FullJid {
bind.jid
}
}
impl From<BindResponse> for Jid {
fn from(bind: BindResponse) -> Jid {
Jid::Full(bind.jid)
}
}
impl TryFrom<Element> for BindResponse { impl TryFrom<Element> for BindResponse {
type Error = Error; type Error = Error;