events: Make some more types non-exhaustive
This commit is contained in:
parent
7b8754b2c9
commit
7c535badf6
@ -12,6 +12,7 @@ pub mod invite;
|
|||||||
|
|
||||||
/// A VoIP session description.
|
/// A VoIP session description.
|
||||||
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
|
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
|
||||||
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
pub struct SessionDescription {
|
pub struct SessionDescription {
|
||||||
/// The type of session description.
|
/// The type of session description.
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "type")]
|
||||||
@ -21,6 +22,13 @@ pub struct SessionDescription {
|
|||||||
pub sdp: String,
|
pub sdp: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl SessionDescription {
|
||||||
|
/// Creates a new `SessionDescription` with the given session type and SDP text.
|
||||||
|
pub fn new(session_type: SessionDescriptionType, sdp: String) -> Self {
|
||||||
|
Self { session_type, sdp }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// The type of VoIP session description.
|
/// The type of VoIP session description.
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Display, EnumString, Deserialize, Serialize)]
|
#[derive(Clone, Copy, Debug, PartialEq, Display, EnumString, Deserialize, Serialize)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
|
@ -12,6 +12,7 @@ pub type AnswerEvent = MessageEvent<AnswerEventContent>;
|
|||||||
|
|
||||||
/// The payload for `AnswerEvent`.
|
/// The payload for `AnswerEvent`.
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize, MessageEventContent)]
|
#[derive(Clone, Debug, Deserialize, Serialize, MessageEventContent)]
|
||||||
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
#[ruma_event(type = "m.call.answer")]
|
#[ruma_event(type = "m.call.answer")]
|
||||||
pub struct AnswerEventContent {
|
pub struct AnswerEventContent {
|
||||||
/// The VoIP session description object. The session description type must be *answer*.
|
/// The VoIP session description object. The session description type must be *answer*.
|
||||||
@ -23,3 +24,10 @@ pub struct AnswerEventContent {
|
|||||||
/// The version of the VoIP specification this messages adheres to.
|
/// The version of the VoIP specification this messages adheres to.
|
||||||
pub version: UInt,
|
pub version: UInt,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl AnswerEventContent {
|
||||||
|
/// Creates an `AnswerEventContent` with the gieven answer, call ID and VoIP version.
|
||||||
|
pub fn new(answer: SessionDescription, call_id: String, version: UInt) -> Self {
|
||||||
|
Self { answer, call_id, version }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -46,9 +46,11 @@ fn deserialize_message_event() {
|
|||||||
answer: SessionDescription {
|
answer: SessionDescription {
|
||||||
session_type: SessionDescriptionType::Answer,
|
session_type: SessionDescriptionType::Answer,
|
||||||
sdp,
|
sdp,
|
||||||
|
..
|
||||||
},
|
},
|
||||||
call_id,
|
call_id,
|
||||||
version,
|
version,
|
||||||
|
..
|
||||||
},
|
},
|
||||||
event_id,
|
event_id,
|
||||||
origin_server_ts,
|
origin_server_ts,
|
||||||
|
@ -89,9 +89,11 @@ fn deserialize_message_call_answer_content() {
|
|||||||
answer: SessionDescription {
|
answer: SessionDescription {
|
||||||
session_type: SessionDescriptionType::Answer,
|
session_type: SessionDescriptionType::Answer,
|
||||||
sdp,
|
sdp,
|
||||||
|
..
|
||||||
},
|
},
|
||||||
call_id,
|
call_id,
|
||||||
version,
|
version,
|
||||||
|
..
|
||||||
}) if sdp == "Hello" && call_id == "foofoo" && version == UInt::new(1).unwrap()
|
}) if sdp == "Hello" && call_id == "foofoo" && version == UInt::new(1).unwrap()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -124,9 +126,11 @@ fn deserialize_message_call_answer() {
|
|||||||
answer: SessionDescription {
|
answer: SessionDescription {
|
||||||
session_type: SessionDescriptionType::Answer,
|
session_type: SessionDescriptionType::Answer,
|
||||||
sdp,
|
sdp,
|
||||||
|
..
|
||||||
},
|
},
|
||||||
call_id,
|
call_id,
|
||||||
version,
|
version,
|
||||||
|
..
|
||||||
}),
|
}),
|
||||||
event_id,
|
event_id,
|
||||||
origin_server_ts,
|
origin_server_ts,
|
||||||
@ -255,9 +259,11 @@ fn deserialize_message_then_convert_to_full() {
|
|||||||
answer: SessionDescription {
|
answer: SessionDescription {
|
||||||
session_type: SessionDescriptionType::Answer,
|
session_type: SessionDescriptionType::Answer,
|
||||||
sdp,
|
sdp,
|
||||||
|
..
|
||||||
},
|
},
|
||||||
call_id,
|
call_id,
|
||||||
version,
|
version,
|
||||||
|
..
|
||||||
}),
|
}),
|
||||||
event_id,
|
event_id,
|
||||||
origin_server_ts,
|
origin_server_ts,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user