Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/add common traits #106

Merged
merged 2 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion jarust/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[derive(thiserror::Error, Debug)]
#[derive(Debug, thiserror::Error)]
pub enum JaError {
/* Transformed Errors */
#[error("Transport: {0}")]
Expand Down
4 changes: 2 additions & 2 deletions jarust/src/jaconfig.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#[derive(Debug)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
pub struct JaConfig {
pub(crate) url: String,
pub(crate) apisecret: Option<String>,
pub(crate) namespace: String,
pub(crate) capacity: usize,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
pub enum TransportType {
Ws,
}
Expand Down
22 changes: 11 additions & 11 deletions jarust/src/japrotocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use serde::Serialize;
use serde_json::Value;

/// The top-level response
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
pub struct JaResponse {
#[serde(flatten)]
pub janus: ResponseType,
Expand All @@ -15,7 +15,7 @@ pub struct JaResponse {
pub establishment_protocol: Option<EstablishmentProtocol>,
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
#[serde(tag = "janus")]
pub enum ResponseType {
#[serde(rename = "error")]
Expand All @@ -32,13 +32,13 @@ pub enum ResponseType {
Event(JaHandleEvent),
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Serialize, Deserialize)]
pub struct ErrorResponse {
pub code: u16,
pub reason: String,
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
#[serde(tag = "janus")]
pub enum JaSuccessProtocol {
#[serde(untagged)]
Expand All @@ -55,13 +55,13 @@ pub struct JaData {
pub id: u64,
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
pub struct PluginData {
pub plugin: String,
pub data: Value,
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
#[serde(tag = "janus")]
pub enum JaHandleEvent {
#[serde(rename = "event")]
Expand All @@ -73,7 +73,7 @@ pub enum JaHandleEvent {
GenericEvent(GenericEvent),
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Serialize, Deserialize)]
#[serde(tag = "janus")]
pub enum GenericEvent {
#[serde(rename = "detached")]
Expand All @@ -96,22 +96,22 @@ pub enum GenericEvent {
Trickle,
}

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Serialize, Deserialize)]
pub enum JsepType {
#[serde(rename = "offer")]
Offer,
#[serde(rename = "answer")]
Answer,
}

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Serialize, Deserialize)]
pub struct Jsep {
#[serde(rename = "type")]
pub jsep_type: JsepType,
pub sdp: String,
}

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Serialize, Deserialize)]
pub struct RTP {
pub ip: String,
pub port: u64,
Expand All @@ -123,7 +123,7 @@ pub struct RTP {
pub fec: Option<bool>,
}

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Serialize, Deserialize)]
pub enum EstablishmentProtocol {
#[serde(rename = "jsep")]
JSEP(Jsep),
Expand Down
4 changes: 2 additions & 2 deletions jarust/src/respones.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use serde::Deserialize;
use serde::Serialize;
use std::collections::HashMap;

#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub struct ServerInfoRsp {
pub name: String,
Expand Down Expand Up @@ -46,7 +46,7 @@ pub struct ServerInfoRsp {
pub plugins: HashMap<String, MetaData>,
}

#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Serialize, Deserialize)]
pub struct MetaData {
name: String,
author: String,
Expand Down
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
Loading