jingle: Add constructors and setters.
This commit is contained in:
parent
c762a03c39
commit
a1e95ffb2e
1 changed files with 73 additions and 0 deletions
|
@ -76,6 +76,45 @@ pub struct Content {
|
||||||
pub security: Option<Element>,
|
pub security: Option<Element>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Content {
|
||||||
|
pub fn new(creator: Creator, name: ContentId) -> Content {
|
||||||
|
Content {
|
||||||
|
creator,
|
||||||
|
name,
|
||||||
|
disposition: Disposition::Session,
|
||||||
|
senders: Senders::Both,
|
||||||
|
description: None,
|
||||||
|
transport: None,
|
||||||
|
security: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_disposition(mut self, disposition: Disposition) -> Content {
|
||||||
|
self.disposition = disposition;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_senders(mut self, senders: Senders) -> Content {
|
||||||
|
self.senders = senders;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_description(mut self, description: Element) -> Content {
|
||||||
|
self.description = Some(description);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_transport(mut self, transport: Element) -> Content {
|
||||||
|
self.transport = Some(transport);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_security(mut self, security: Element) -> Content {
|
||||||
|
self.security = Some(security);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl TryFrom<Element> for Content {
|
impl TryFrom<Element> for Content {
|
||||||
type Err = Error;
|
type Err = Error;
|
||||||
|
|
||||||
|
@ -267,6 +306,40 @@ pub struct Jingle {
|
||||||
pub other: Vec<Element>,
|
pub other: Vec<Element>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Jingle {
|
||||||
|
pub fn new(action: Action, sid: SessionId) -> Jingle {
|
||||||
|
Jingle {
|
||||||
|
action: action,
|
||||||
|
sid: sid,
|
||||||
|
initiator: None,
|
||||||
|
responder: None,
|
||||||
|
contents: Vec::new(),
|
||||||
|
reason: None,
|
||||||
|
other: Vec::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_initiator(mut self, initiator: Jid) -> Jingle {
|
||||||
|
self.initiator = Some(initiator);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_responder(mut self, responder: Jid) -> Jingle {
|
||||||
|
self.responder = Some(responder);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn add_content(mut self, content: Content) -> Jingle {
|
||||||
|
self.contents.push(content);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_reason(mut self, content: Content) -> Jingle {
|
||||||
|
self.contents.push(content);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl TryFrom<Element> for Jingle {
|
impl TryFrom<Element> for Jingle {
|
||||||
type Err = Error;
|
type Err = Error;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue