diff --git a/src/jingle.rs b/src/jingle.rs index 84600f4..ca9858a 100644 --- a/src/jingle.rs +++ b/src/jingle.rs @@ -245,12 +245,29 @@ impl IntoElements for ReasonElement { } } +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct Sid(String); + +impl FromStr for Sid { + type Err = Error; + fn from_str(s: &str) -> Result { + // TODO: implement the NMTOKEN restrictions: https://www.w3.org/TR/2000/WD-xml-2e-20000814#NT-Nmtoken + Ok(Sid(String::from(s))) + } +} + +impl IntoAttributeValue for Sid { + fn into_attribute_value(self) -> Option { + return Some(self.0); + } +} + #[derive(Debug, Clone)] pub struct Jingle { pub action: Action, pub initiator: Option, pub responder: Option, - pub sid: String, + pub sid: Sid, pub contents: Vec, pub reason: Option, pub other: Vec,