mirror of
https://github.com/danbulant/cushy
synced 2026-07-05 11:10:34 +00:00
serde feature
This commit is contained in:
parent
7e69846909
commit
8eaf0f414f
7 changed files with 53 additions and 18 deletions
|
|
@ -130,6 +130,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
`ModifiersState` type. Specifically, this trait adds an associated `PRIMARY`
|
`ModifiersState` type. Specifically, this trait adds an associated `PRIMARY`
|
||||||
constant that resolves to the primary shortcut modifier on the target
|
constant that resolves to the primary shortcut modifier on the target
|
||||||
platform.
|
platform.
|
||||||
|
- New feature flag `serde` enables serialization support for some types.
|
||||||
|
|
||||||
|
|
||||||
[139]: https://github.com/khonsulabs/cushy/issues/139
|
[139]: https://github.com/khonsulabs/cushy/issues/139
|
||||||
|
|
|
||||||
22
Cargo.lock
generated
22
Cargo.lock
generated
|
|
@ -685,6 +685,7 @@ dependencies = [
|
||||||
"png",
|
"png",
|
||||||
"pollster",
|
"pollster",
|
||||||
"rand",
|
"rand",
|
||||||
|
"serde",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
|
|
@ -766,9 +767,9 @@ checksum = "f25c0e292a7ca6d6498557ff1df68f32c99850012b6ea401cf8daf771f22ff53"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "easing-function"
|
name = "easing-function"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5699e572f2ece3d6ea49a528341097d26117751ea0a8ed3adab747bb6e96c480"
|
checksum = "1ff18235504129e34c411871066cfa4ad108ed6a28d5fb2417057aff7f99bee4"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "either"
|
name = "either"
|
||||||
|
|
@ -863,6 +864,7 @@ dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"euclid",
|
"euclid",
|
||||||
"intentional",
|
"intentional",
|
||||||
|
"serde",
|
||||||
"wgpu",
|
"wgpu",
|
||||||
"winit",
|
"winit",
|
||||||
]
|
]
|
||||||
|
|
@ -2124,9 +2126,9 @@ checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "plotters"
|
name = "plotters"
|
||||||
version = "0.3.6"
|
version = "0.3.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a15b6eccb8484002195a3e44fe65a4ce8e93a625797a063735536fd59cb01cf3"
|
checksum = "5aeb6f403d7a4911efb1e33402027fc44f29b5bf6def3effcc22d7bb75f2b747"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"plotters-backend",
|
"plotters-backend",
|
||||||
|
|
@ -2596,18 +2598,18 @@ checksum = "d369a96f978623eb3dc28807c4852d6cc617fed53da5d3c400feff1ef34a714a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.209"
|
version = "1.0.210"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09"
|
checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.209"
|
version = "1.0.210"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170"
|
checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
|
@ -2922,9 +2924,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio"
|
name = "tokio"
|
||||||
version = "1.39.3"
|
version = "1.40.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9babc99b9923bfa4804bd74722ff02c0381021eafa4db9949217e3be8e84fff5"
|
checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"backtrace",
|
"backtrace",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ roboto-flex = []
|
||||||
plotters = ["dep:plotters", "kludgine/plotters"]
|
plotters = ["dep:plotters", "kludgine/plotters"]
|
||||||
tokio = ["dep:tokio"]
|
tokio = ["dep:tokio"]
|
||||||
tokio-multi-thread = ["tokio", "tokio/rt-multi-thread"]
|
tokio-multi-thread = ["tokio", "tokio/rt-multi-thread"]
|
||||||
|
serde = ["dep:serde", "figures/serde"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
kludgine = { git = "https://github.com/khonsulabs/kludgine", features = [
|
kludgine = { git = "https://github.com/khonsulabs/kludgine", features = [
|
||||||
|
|
@ -31,7 +32,7 @@ interner = "0.2.1"
|
||||||
kempt = "0.2.1"
|
kempt = "0.2.1"
|
||||||
intentional = "0.1.0"
|
intentional = "0.1.0"
|
||||||
tracing = "0.1.40"
|
tracing = "0.1.40"
|
||||||
tokio = { version = "1.37.0", optional = true, features = ["rt"] }
|
tokio = { version = "1.40.0", optional = true, features = ["rt"] }
|
||||||
|
|
||||||
tracing-subscriber = { version = "0.3", optional = true, features = [
|
tracing-subscriber = { version = "0.3", optional = true, features = [
|
||||||
"env-filter",
|
"env-filter",
|
||||||
|
|
@ -45,10 +46,11 @@ unicode-segmentation = "1.10.1"
|
||||||
pollster = "0.3.0"
|
pollster = "0.3.0"
|
||||||
png = "0.17.10"
|
png = "0.17.10"
|
||||||
image = { version = "0.25.0", features = ["png"] }
|
image = { version = "0.25.0", features = ["png"] }
|
||||||
plotters = { version = "0.3.5", default-features = false, optional = true }
|
plotters = { version = "0.3.7", default-features = false, optional = true }
|
||||||
nominals = "0.3.0"
|
nominals = "0.3.0"
|
||||||
parking_lot = "0.12.1"
|
parking_lot = "0.12.1"
|
||||||
easing-function = "0.1.0"
|
easing-function = "0.1.1"
|
||||||
|
serde = { version = "1.0.210", features = ["derive"], optional = true }
|
||||||
|
|
||||||
|
|
||||||
# [patch.crates-io]
|
# [patch.crates-io]
|
||||||
|
|
|
||||||
|
|
@ -1188,6 +1188,8 @@ fn color_lerp() {
|
||||||
///
|
///
|
||||||
/// Because of these restrictions, this type implements `Ord` and `Eq`.
|
/// Because of these restrictions, this type implements `Ord` and `Eq`.
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
|
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||||
|
#[cfg_attr(feature = "serde", serde(transparent))]
|
||||||
pub struct ZeroToOne(f32);
|
pub struct ZeroToOne(f32);
|
||||||
|
|
||||||
impl ZeroToOne {
|
impl ZeroToOne {
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,7 @@ impl Styles {
|
||||||
context: &WidgetContext<'_>,
|
context: &WidgetContext<'_>,
|
||||||
) -> Fallback::ComponentType
|
) -> Fallback::ComponentType
|
||||||
where
|
where
|
||||||
Fallback: ComponentDefinition + ?Sized,
|
Fallback: ComponentDefinition,
|
||||||
{
|
{
|
||||||
self.0
|
self.0
|
||||||
.components
|
.components
|
||||||
|
|
@ -166,7 +166,7 @@ impl Styles {
|
||||||
context: &WidgetContext<'_>,
|
context: &WidgetContext<'_>,
|
||||||
) -> Option<Named::ComponentType>
|
) -> Option<Named::ComponentType>
|
||||||
where
|
where
|
||||||
Named: ComponentDefinition + ?Sized,
|
Named: ComponentDefinition,
|
||||||
{
|
{
|
||||||
self.0
|
self.0
|
||||||
.components
|
.components
|
||||||
|
|
@ -179,7 +179,7 @@ impl Styles {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn get<Named>(&self, component: &Named, context: &WidgetContext<'_>) -> Named::ComponentType
|
pub fn get<Named>(&self, component: &Named, context: &WidgetContext<'_>) -> Named::ComponentType
|
||||||
where
|
where
|
||||||
Named: ComponentDefinition + ?Sized,
|
Named: ComponentDefinition,
|
||||||
{
|
{
|
||||||
self.try_get(component, context)
|
self.try_get(component, context)
|
||||||
.unwrap_or_else(|| component.default_value(context))
|
.unwrap_or_else(|| component.default_value(context))
|
||||||
|
|
@ -680,6 +680,7 @@ impl TryFrom<Component> for CornerRadii<Dimension> {
|
||||||
|
|
||||||
/// A 1-dimensional measurement that may be automatically calculated.
|
/// A 1-dimensional measurement that may be automatically calculated.
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
|
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||||
pub enum FlexibleDimension {
|
pub enum FlexibleDimension {
|
||||||
/// Automatically calculate this dimension.
|
/// Automatically calculate this dimension.
|
||||||
Auto,
|
Auto,
|
||||||
|
|
@ -733,6 +734,7 @@ impl From<Lp> for FlexibleDimension {
|
||||||
|
|
||||||
/// A 1-dimensional measurement.
|
/// A 1-dimensional measurement.
|
||||||
#[derive(Clone, Copy, Eq, PartialEq)]
|
#[derive(Clone, Copy, Eq, PartialEq)]
|
||||||
|
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||||
pub enum Dimension {
|
pub enum Dimension {
|
||||||
/// Physical Pixels
|
/// Physical Pixels
|
||||||
Px(Px),
|
Px(Px),
|
||||||
|
|
@ -863,6 +865,7 @@ impl Div<f32> for Dimension {
|
||||||
|
|
||||||
/// A range of [`Dimension`]s.
|
/// A range of [`Dimension`]s.
|
||||||
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
|
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
|
||||||
|
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||||
pub struct DimensionRange {
|
pub struct DimensionRange {
|
||||||
/// The start bound of the range.
|
/// The start bound of the range.
|
||||||
pub start: Bound<Dimension>,
|
pub start: Bound<Dimension>,
|
||||||
|
|
@ -2078,6 +2081,7 @@ impl From<Hsl> for Color {
|
||||||
|
|
||||||
/// A 2d ordering configuration.
|
/// A 2d ordering configuration.
|
||||||
#[derive(Copy, Debug, Clone, Eq, PartialEq)]
|
#[derive(Copy, Debug, Clone, Eq, PartialEq)]
|
||||||
|
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||||
pub struct VisualOrder {
|
pub struct VisualOrder {
|
||||||
/// The ordering to apply horizontally.
|
/// The ordering to apply horizontally.
|
||||||
pub horizontal: HorizontalOrder,
|
pub horizontal: HorizontalOrder,
|
||||||
|
|
@ -2139,6 +2143,7 @@ impl RequireInvalidation for VisualOrder {
|
||||||
|
|
||||||
/// A horizontal direction.
|
/// A horizontal direction.
|
||||||
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
||||||
|
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||||
pub enum HorizontalOrder {
|
pub enum HorizontalOrder {
|
||||||
/// Describes an order starting at the left and proceeding to the right.
|
/// Describes an order starting at the left and proceeding to the right.
|
||||||
LeftToRight,
|
LeftToRight,
|
||||||
|
|
@ -2166,6 +2171,7 @@ impl HorizontalOrder {
|
||||||
|
|
||||||
/// A vertical direction.
|
/// A vertical direction.
|
||||||
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
||||||
|
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||||
pub enum VerticalOrder {
|
pub enum VerticalOrder {
|
||||||
/// Describes an order starting at the top and proceeding to the bottom.
|
/// Describes an order starting at the top and proceeding to the bottom.
|
||||||
TopToBottom,
|
TopToBottom,
|
||||||
|
|
@ -2201,6 +2207,7 @@ impl VerticalOrder {
|
||||||
/// A configuration option to control which controls should be able to receive
|
/// A configuration option to control which controls should be able to receive
|
||||||
/// focus through keyboard focus handling or initial focus handling.
|
/// focus through keyboard focus handling or initial focus handling.
|
||||||
#[derive(Debug, Default, Copy, Clone, Eq, PartialEq)]
|
#[derive(Debug, Default, Copy, Clone, Eq, PartialEq)]
|
||||||
|
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||||
pub enum FocusableWidgets {
|
pub enum FocusableWidgets {
|
||||||
/// Allow all widgets that can respond to keyboard input to accept focus.
|
/// Allow all widgets that can respond to keyboard input to accept focus.
|
||||||
#[default]
|
#[default]
|
||||||
|
|
@ -2249,6 +2256,7 @@ impl RequireInvalidation for FocusableWidgets {
|
||||||
/// A description of the level of depth a
|
/// A description of the level of depth a
|
||||||
/// [`Container`](crate::widgets::Container) is nested at.
|
/// [`Container`](crate::widgets::Container) is nested at.
|
||||||
#[derive(Default, Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd)]
|
#[derive(Default, Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd)]
|
||||||
|
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||||
pub enum ContainerLevel {
|
pub enum ContainerLevel {
|
||||||
/// The lowest container level.
|
/// The lowest container level.
|
||||||
#[default]
|
#[default]
|
||||||
|
|
|
||||||
|
|
@ -1524,6 +1524,26 @@ macro_rules! impl_cow_string {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> InputValue<$type> for T where T: IntoDynamic<$type> {}
|
impl<T> InputValue<$type> for T where T: IntoDynamic<$type> {}
|
||||||
|
|
||||||
|
#[cfg(feature = "serde")]
|
||||||
|
impl serde::Serialize for $type {
|
||||||
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
|
where
|
||||||
|
S: serde::Serializer,
|
||||||
|
{
|
||||||
|
self.0.serialize(serializer)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "serde")]
|
||||||
|
impl<'de> serde::Deserialize<'de> for $type {
|
||||||
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||||
|
where
|
||||||
|
D: serde::Deserializer<'de>,
|
||||||
|
{
|
||||||
|
String::deserialize(deserializer).map(Self::from)
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1018,8 +1018,8 @@ where
|
||||||
/// - `WM_CLASS` on X11
|
/// - `WM_CLASS` on X11
|
||||||
/// - application ID on wayland
|
/// - application ID on wayland
|
||||||
/// - class name on windows
|
/// - class name on windows
|
||||||
pub fn app_name(mut self, name: String) -> Self {
|
pub fn app_name(mut self, name: impl Into<String>) -> Self {
|
||||||
self.attributes.app_name = Some(name);
|
self.attributes.app_name = Some(name.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue