Skip to content

Commit

Permalink
feat(plugins): added common traits on dtos
Browse files Browse the repository at this point in the history
  • Loading branch information
Ghamza-Jd committed Jun 26, 2024
1 parent 21ddbf7 commit 636adc5
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions jarust_plugins/src/audio_bridge/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use serde::Serialize;
/// Rooms and Participants Identifier.
///
/// Identifier should be by default unsigned integer, unless configured otherwise in the audiobridge config.
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Serialize, Deserialize)]
#[serde(untagged)]
pub enum Identifier {
/// String Identifier
Expand All @@ -13,7 +13,7 @@ pub enum Identifier {
Uint(u64),
}

#[derive(PartialEq, Debug, Deserialize)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Deserialize)]
pub struct Participant {
pub id: Identifier,
pub display: Option<String>,
Expand Down
6 changes: 3 additions & 3 deletions jarust_plugins/src/audio_bridge/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use jarust::japrotocol::ResponseType;
use serde::Deserialize;
use serde_json::from_value;

#[derive(Debug, PartialEq, Deserialize)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Deserialize)]
#[serde(tag = "audiobridge")]
enum AudioBridgeEventDto {
#[serde(rename = "joined")]
Expand All @@ -36,13 +36,13 @@ enum AudioBridgeEventDto {
},
}

#[derive(Debug, PartialEq)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
pub enum PluginEvent {
AudioBridgeEvent(AudioBridgeEvent),
GenericEvent(GenericEvent),
}

#[derive(Debug, PartialEq)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
pub enum AudioBridgeEvent {
RoomJoinedWithEstabilshment {
id: Identifier,
Expand Down
12 changes: 6 additions & 6 deletions jarust_plugins/src/audio_bridge/msg_opitons.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::common::Identifier;
use serde::Serialize;

#[derive(Serialize, Default)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Default, Serialize)]
pub struct CreateRoomOptions {
/// unique numeric ID, chosen by plugin if missing
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -95,7 +95,7 @@ pub struct CreateRoomOptions {
pub groups: Option<Vec<String>>,
}

#[derive(Serialize, Default)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Default, Serialize)]
pub struct EditRoomOptions {
/// room secret, mandatory if configured
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -130,15 +130,15 @@ pub struct EditRoomOptions {
pub permanent: Option<bool>,
}

#[derive(Serialize, Default)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Default, Serialize)]
pub struct DestroyRoomMsg {
#[serde(skip_serializing_if = "Option::is_none")]
pub secret: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub permanent: Option<bool>,
}

#[derive(Serialize, Default)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Default, Serialize)]
pub struct JoinRoomOptions {
/// Unique ID to assign to the participant, assigned by the plugin if missing
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -236,7 +236,7 @@ pub struct JoinRoomOptions {
pub generate_offer: Option<bool>,
}

#[derive(Serialize)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Serialize)]
pub struct AllowedOptions {
pub action: AllowAction,

Expand All @@ -248,7 +248,7 @@ pub struct AllowedOptions {
pub secret: Option<String>,
}

#[derive(Serialize)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum AllowAction {
Enable,
Expand Down
16 changes: 8 additions & 8 deletions jarust_plugins/src/audio_bridge/responses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@ use super::common::Identifier;
use super::common::Participant;
use serde::Deserialize;

#[derive(Debug, Deserialize)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Deserialize)]
pub struct RoomCreatedRsp {
pub room: Identifier,
pub permanent: bool,
}

#[derive(Debug, Deserialize)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Deserialize)]
pub struct RoomEditedRsp {
pub room: Identifier,
pub permanent: bool,
}

#[derive(Debug, Deserialize)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Deserialize)]
pub struct RoomDestroyedRsp {
pub room: Identifier,
pub permanent: bool,
}

#[derive(Debug, Deserialize)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Deserialize)]
pub struct ListRoomsRsp {
pub list: Vec<Room>,
}

#[derive(Debug, Deserialize)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Deserialize)]
pub struct Room {
pub room: Identifier,
pub description: String,
Expand All @@ -37,19 +37,19 @@ pub struct Room {
pub muted: bool,
}

#[derive(Debug, Deserialize)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Deserialize)]
pub struct AllowedRsp {
pub room: Identifier,
pub allowed: Vec<String>,
}

#[derive(Debug, Deserialize)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Deserialize)]
pub struct ExistsRoomRsp {
pub room: Identifier,
pub exists: bool,
}

#[derive(Debug, Deserialize)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Deserialize)]
pub struct ListParticipantsRsp {
pub room: Identifier,
pub participants: Vec<Participant>,
Expand Down
6 changes: 3 additions & 3 deletions jarust_plugins/src/echo_test/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ use jarust::japrotocol::ResponseType;
use serde::Deserialize;
use serde_json::from_value;

#[derive(Debug, Deserialize, Clone)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Deserialize)]
enum EchoTestEventDto {
#[serde(untagged)]
Result { echotest: String, result: String },
}

#[derive(Debug, PartialEq)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
pub enum PluginEvent {
EchoTestEvent(EchoTestEvent),
GenericEvent(GenericEvent),
}

#[derive(Debug, PartialEq)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
pub enum EchoTestEvent {
Result {
echotest: String,
Expand Down
2 changes: 1 addition & 1 deletion jarust_plugins/src/echo_test/msg_options.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use serde::Serialize;

#[derive(Serialize, Default)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Default, Serialize)]
pub struct StartOptions {
pub audio: bool,
pub video: bool,
Expand Down
2 changes: 1 addition & 1 deletion jarust_plugins/src/video_room/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use jarust::error::JaError;
use jarust::japrotocol::GenericEvent;
use jarust::japrotocol::JaResponse;

#[derive(Debug, PartialEq)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
pub enum PluginEvent {
GenericEvent(GenericEvent),
}
Expand Down

0 comments on commit 636adc5

Please sign in to comment.