feat: derive serde for more types

This commit is contained in:
Amr Bashir 2023-08-16 19:37:19 +03:00
parent 866eb38906
commit 47d1808090
No known key found for this signature in database
GPG key ID: BBD7A47A2003FF33
6 changed files with 11 additions and 0 deletions

5
.changes/serde.md Normal file
View file

@ -0,0 +1,5 @@
---
"muda": "patch"
---
Derive `serde` for more types.

View file

@ -2,6 +2,7 @@ use crate::icon::Icon;
/// Application metadata for the [`PredefinedMenuItem::about`](crate::PredefinedMenuItem::about). /// Application metadata for the [`PredefinedMenuItem::about`](crate::PredefinedMenuItem::about).
#[derive(Debug, Clone, Default)] #[derive(Debug, Clone, Default)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct AboutMetadata { pub struct AboutMetadata {
/// Sets the application name. /// Sets the application name.
pub name: Option<String>, pub name: Option<String>,

View file

@ -39,6 +39,7 @@ pub const CMD_OR_CTRL: Modifiers = Modifiers::CONTROL;
/// of modifier keys (provided by [`Modifiers`](crate::accelerator::Modifiers)) and /// of modifier keys (provided by [`Modifiers`](crate::accelerator::Modifiers)) and
/// one key ([`Code`](crate::accelerator::Code)). /// one key ([`Code`](crate::accelerator::Code)).
#[derive(Debug, Clone, PartialEq, Eq, Hash, Copy)] #[derive(Debug, Clone, PartialEq, Eq, Hash, Copy)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Accelerator { pub struct Accelerator {
pub(crate) mods: Modifiers, pub(crate) mods: Modifiers,
pub(crate) key: Code, pub(crate) key: Code,

View file

@ -171,6 +171,7 @@ impl Icon {
/// ///
/// - **Windows / Linux**: Unsupported. /// - **Windows / Linux**: Unsupported.
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum NativeIcon { pub enum NativeIcon {
/// An add item template image. /// An add item template image.
Add, Add,

View file

@ -259,6 +259,7 @@ pub unsafe trait IsMenuItem {
} }
#[derive(Debug, PartialEq, PartialOrd, Clone, Copy)] #[derive(Debug, PartialEq, PartialOrd, Clone, Copy)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub(crate) enum MenuItemType { pub(crate) enum MenuItemType {
MenuItem, MenuItem,
Submenu, Submenu,
@ -324,6 +325,7 @@ pub trait ContextMenu {
/// Describes a menu event emitted when a menu item is activated /// Describes a menu event emitted when a menu item is activated
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct MenuEvent { pub struct MenuEvent {
/// Id of the menu item which triggered this event /// Id of the menu item which triggered this event
pub id: MenuId, pub id: MenuId,

View file

@ -2,6 +2,7 @@ use std::{convert::Infallible, str::FromStr};
/// An unique id that is associated with a menu or a menu item. /// An unique id that is associated with a menu or a menu item.
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Default, Hash)] #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Default, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct MenuId(pub String); pub struct MenuId(pub String);
impl MenuId { impl MenuId {