Skip to content

Commit

Permalink
Add serde derives to extension types
Browse files Browse the repository at this point in the history
  • Loading branch information
Ovenoboyo committed Aug 30, 2024
1 parent 9cfdf0a commit 730afac
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src-tauri/types/src/extensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{
ui::player_details::PlayerState,
};

#[derive(Serialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct GenericExtensionHostRequest<T: Serialize> {
#[serde(rename = "type")]
Expand All @@ -34,23 +34,23 @@ impl From<String> for PackageNameArgs {
}
}

#[derive(Serialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]

pub struct ToggleExtArgs {
pub package_name: String,
pub toggle: bool,
}

#[derive(Serialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct ContextMenuActionArgs {
pub package_name: String,
pub id: String,
pub arg: Value,
}

#[derive(Serialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct AccountLoginArgs {
pub package_name: String,
Expand Down Expand Up @@ -88,7 +88,7 @@ impl PartialEq for ExtensionDetail {
}
}

#[derive(Deserialize, Debug, Clone)]
#[derive(Deserialize, Serialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct ExtensionContextMenuItem {
#[serde(rename = "type")]
Expand All @@ -99,7 +99,7 @@ pub struct ExtensionContextMenuItem {
pub handler: String,
}

#[derive(Deserialize, Debug, Clone)]
#[derive(Deserialize, Serialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct ExtensionAccountDetail {
pub id: String,
Expand All @@ -111,7 +111,7 @@ pub struct ExtensionAccountDetail {
pub username: Option<String>,
}

#[derive(Deserialize, Debug, Clone, PartialEq, Eq)]
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub enum ExtensionProviderScope {
Search,
Expand Down Expand Up @@ -171,26 +171,26 @@ pub struct ExtensionExtraEventArgs {
pub package_name: String,
}

#[derive(Deserialize)]
#[derive(Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct PlaylistReturnType {
pub playlists: Vec<QueryablePlaylist>,
}

#[derive(Deserialize)]
#[derive(Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct SongsReturnType {
pub songs: Vec<Song>,
}

#[derive(Deserialize)]
#[derive(Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct SongsWithPageTokenReturnType {
pub songs: Vec<Song>,
pub next_page_token: Option<serde_json::Value>,
}

#[derive(Deserialize, Debug)]
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct SearchReturnType {
pub songs: Vec<Song>,
Expand All @@ -199,35 +199,35 @@ pub struct SearchReturnType {
pub albums: Vec<QueryableAlbum>,
}

#[derive(Deserialize)]
#[derive(Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct PlaybackDetailsReturnType {
pub duration: u32,
pub url: String,
}

#[derive(Deserialize, Debug)]
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct CustomRequestReturnType {
pub mime_type: Option<String>,
pub data: Option<Vec<u8>>, // Buffer is typically represented as Vec<u8> in Rust
pub redirect_url: Option<String>,
}

#[derive(Deserialize)]
#[derive(Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct SongReturnType {
pub song: Song,
}

#[derive(Deserialize)]
#[derive(Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct PlaylistAndSongsReturnType {
pub playlist: Option<QueryablePlaylist>,
pub songs: Option<Vec<Song>>,
}

#[derive(Deserialize)]
#[derive(Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct RecommendationsReturnType {
pub songs: Vec<Song>,
Expand Down

0 comments on commit 730afac

Please sign in to comment.