mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
jingle: Specialise Sid to get an increased type safety.
This commit is contained in:
parent
216f6f8389
commit
48d340120c
1 changed files with 18 additions and 1 deletions
|
@ -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<Sid, Error> {
|
||||
// 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<String> {
|
||||
return Some(self.0);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Jingle {
|
||||
pub action: Action,
|
||||
pub initiator: Option<Jid>,
|
||||
pub responder: Option<Jid>,
|
||||
pub sid: String,
|
||||
pub sid: Sid,
|
||||
pub contents: Vec<Content>,
|
||||
pub reason: Option<ReasonElement>,
|
||||
pub other: Vec<Element>,
|
||||
|
|
Loading…
Reference in a new issue