ruma_events/call/
select_answer.rs

1//! Types for the [`m.call.select_answer`] event.
2//!
3//! [`m.call.select_answer`]: https://spec.matrix.org/latest/client-server-api/#mcallselect_answer
4
5use ruma_common::{OwnedVoipId, VoipVersionId};
6use ruma_macros::EventContent;
7use serde::{Deserialize, Serialize};
8
9/// **Added in VoIP version 1.** The content of an `m.call.select_answer` event.
10///
11/// This event is sent by the caller when it has chosen an answer.
12#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
13#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
14#[ruma_event(type = "m.call.select_answer", kind = MessageLike)]
15pub struct CallSelectAnswerEventContent {
16    /// The ID of the call this event relates to.
17    pub call_id: OwnedVoipId,
18
19    /// A unique ID for this session for the duration of the call.
20    ///
21    /// Must be the same as the one sent by the previous invite from this session.
22    pub party_id: OwnedVoipId,
23
24    /// The party ID of the selected answer to the previously sent invite.
25    pub selected_party_id: OwnedVoipId,
26
27    /// The version of the VoIP specification this messages adheres to.
28    ///
29    /// Cannot be older than `VoipVersionId::V1`.
30    pub version: VoipVersionId,
31}
32
33impl CallSelectAnswerEventContent {
34    /// Creates a `CallSelectAnswerEventContent` with the given call ID, VoIP version, party ID and
35    /// selected party ID.
36    pub fn new(
37        call_id: OwnedVoipId,
38        party_id: OwnedVoipId,
39        selected_party_id: OwnedVoipId,
40        version: VoipVersionId,
41    ) -> Self {
42        Self { call_id, party_id, selected_party_id, version }
43    }
44
45    /// Convenience method to create a version 1 `CallSelectAnswerEventContent` with all the
46    /// required fields.
47    pub fn version_1(
48        call_id: OwnedVoipId,
49        party_id: OwnedVoipId,
50        selected_party_id: OwnedVoipId,
51    ) -> Self {
52        Self::new(call_id, party_id, selected_party_id, VoipVersionId::V1)
53    }
54}