mirror of
https://github.com/italicsjenga/muda.git
synced 2024-12-23 20:11:29 +11:00
feat: derive serde for more types
This commit is contained in:
parent
866eb38906
commit
47d1808090
5
.changes/serde.md
Normal file
5
.changes/serde.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
"muda": "patch"
|
||||||
|
---
|
||||||
|
|
||||||
|
Derive `serde` for more types.
|
|
@ -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>,
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
Loading…
Reference in a new issue