jingle: Implement From for String on all special attributes.

This commit is contained in:
Emmanuel Gil Peyrot 2017-04-24 19:25:00 +01:00
parent 90f1792ebc
commit fa10ab4ebc

View file

@ -52,6 +52,28 @@ impl FromStr for Action {
} }
} }
impl From<Action> for String {
fn from(action: Action) -> String {
String::from(match action {
Action::ContentAccept => "content-accept",
Action::ContentAdd => "content-add",
Action::ContentModify => "content-modify",
Action::ContentReject => "content-reject",
Action::ContentRemove => "content-remove",
Action::DescriptionInfo => "description-info",
Action::SecurityInfo => "security-info",
Action::SessionAccept => "session-accept",
Action::SessionInfo => "session-info",
Action::SessionInitiate => "session-initiate",
Action::SessionTerminate => "session-terminate",
Action::TransportAccept => "transport-accept",
Action::TransportInfo => "transport-info",
Action::TransportReject => "transport-reject",
Action::TransportReplace => "transport-replace",
})
}
}
// TODO: use a real JID type. // TODO: use a real JID type.
type Jid = String; type Jid = String;
@ -74,6 +96,15 @@ impl FromStr for Creator {
} }
} }
impl From<Creator> for String {
fn from(creator: Creator) -> String {
String::from(match creator {
Creator::Initiator => "initiator",
Creator::Responder => "responder",
})
}
}
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
pub enum Senders { pub enum Senders {
Both, Both,
@ -97,6 +128,17 @@ impl FromStr for Senders {
} }
} }
impl From<Senders> for String {
fn from(senders: Senders) -> String {
String::from(match senders {
Senders::Both => "both",
Senders::Initiator => "initiator",
Senders::None_ => "none",
Senders::Responder => "responder",
})
}
}
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct Content { pub struct Content {
pub creator: Creator, pub creator: Creator,