events: Make remaining types in call::* non-exhaustive

This commit is contained in:
Jonas Platte 2021-05-16 23:16:24 +02:00
parent 0ad480a163
commit 062c2cc55b
No known key found for this signature in database
GPG Key ID: 7D261D771D915378
3 changed files with 33 additions and 0 deletions

View File

@ -12,6 +12,7 @@ pub type CandidatesEvent = MessageEvent<CandidatesEventContent>;
/// The payload for `CandidatesEvent`.
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.call.candidates", kind = Message)]
pub struct CandidatesEventContent {
/// The ID of the call this event relates to.
@ -24,8 +25,17 @@ pub struct CandidatesEventContent {
pub version: UInt,
}
impl CandidatesEventContent {
/// Creates a new `CandidatesEventContent` with the given call id, candidate list and VoIP
/// version.
pub fn new(call_id: String, candidates: Vec<Candidate>, version: UInt) -> Self {
Self { call_id, candidates, version }
}
}
/// An ICE (Interactive Connectivity Establishment) candidate.
#[derive(Clone, Debug, Deserialize, Serialize)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[serde(rename_all = "camelCase")]
pub struct Candidate {
/// The SDP "a" line of the candidate.
@ -37,3 +47,10 @@ pub struct Candidate {
/// The index of the SDP "m" line this candidate is intended for.
pub sdp_m_line_index: UInt,
}
impl Candidate {
/// Creates a new `Candidate` with the given "a" line, SDP media type and SDP "m" line.
pub fn new(candidate: String, sdp_mid: String, sdp_m_line_index: UInt) -> Self {
Self { candidate, sdp_mid, sdp_m_line_index }
}
}

View File

@ -13,6 +13,7 @@ pub type HangupEvent = MessageEvent<HangupEventContent>;
/// The payload for `HangupEvent`.
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.call.hangup", kind = Message)]
pub struct HangupEventContent {
/// The ID of the call this event relates to.
@ -26,6 +27,13 @@ pub struct HangupEventContent {
pub reason: Option<Reason>,
}
impl HangupEventContent {
/// Creates a new `HangupEventContent` with the given call ID and VoIP version.
pub fn new(call_id: String, version: UInt) -> Self {
Self { call_id, version, reason: None }
}
}
/// A reason for a hangup.
///
/// This should not be provided when the user naturally ends or rejects the call. When there was an

View File

@ -12,6 +12,7 @@ pub type InviteEvent = MessageEvent<InviteEventContent>;
/// The payload for `InviteEvent`.
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.call.invite", kind = Message)]
pub struct InviteEventContent {
/// A unique identifier for the call.
@ -28,3 +29,10 @@ pub struct InviteEventContent {
/// The version of the VoIP specification this messages adheres to.
pub version: UInt,
}
impl InviteEventContent {
/// Creates a new `InviteEventContent` with the given call ID, lifetime and VoIP version.
pub fn new(call_id: String, lifetime: UInt, offer: SessionDescription, version: UInt) -> Self {
Self { call_id, lifetime, offer, version }
}
}