From fa10ab4ebc340ed0adcf173f9e851e035952cd09 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Mon, 24 Apr 2017 19:25:00 +0100 Subject: [PATCH] jingle: Implement From for String on all special attributes. --- src/jingle.rs | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/jingle.rs b/src/jingle.rs index 9cea6cf8..c8a2dfc0 100644 --- a/src/jingle.rs +++ b/src/jingle.rs @@ -52,6 +52,28 @@ impl FromStr for Action { } } +impl From 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. type Jid = String; @@ -74,6 +96,15 @@ impl FromStr for Creator { } } +impl From for String { + fn from(creator: Creator) -> String { + String::from(match creator { + Creator::Initiator => "initiator", + Creator::Responder => "responder", + }) + } +} + #[derive(Debug, Clone, PartialEq)] pub enum Senders { Both, @@ -97,6 +128,17 @@ impl FromStr for Senders { } } +impl From 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)] pub struct Content { pub creator: Creator,