gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 5364Rust 86Markdown 12TOML 91841 Definiciones

Increase coverage of serde derives

495c673d051fa463e506e95cf23db2b4eedcec71 · por Nico Burns · (hace 2 años) · padre d099aaf21 · ver el árbol en este commit

Delta semántico

Ninguna definición cambió: el cambio es de texto, documentación o datos.

3 archivos · +10 −0

diff --git a/src/style/dimension.rs b/src/style/dimension.rs
index fb5e910b9..35ee8d27a 100644
--- a/src/style/dimension.rs
+++ b/src/style/dimension.rs
@@ -179,6 +179,7 @@ impl Rect<Dimension> {
 /// The amount of space available to a node in a given axis
 /// <https://www.w3.org/TR/css-sizing-3/#available>
 #[derive(Copy, Clone, Debug, PartialEq)]
+#[cfg_attr(feature = "serde", derive(Serialize))]
 pub enum AvailableSpace {
     /// The amount of space available is the specified number of pixels
     Definite(f32),
diff --git a/src/tree/cache.rs b/src/tree/cache.rs
index c131158ab..43c18b84d 100644
--- a/src/tree/cache.rs
+++ b/src/tree/cache.rs
@@ -8,6 +8,7 @@ const CACHE_SIZE: usize = 9;
 
 /// Cached intermediate layout results
 #[derive(Debug, Clone, Copy)]
+#[cfg_attr(feature = "serde", derive(Serialize))]
 pub(crate) struct CacheEntry<T> {
     /// The initial cached size of the node itself
     known_dimensions: Size<Option<f32>>,
@@ -18,6 +19,7 @@ pub(crate) struct CacheEntry<T> {
 }
 
 /// A cache for caching the results of a sizing a Grid Item or Flexbox Item
+#[cfg_attr(feature = "serde", derive(Serialize))]
 pub struct Cache {
     /// The cache entry for the node's final layout
     final_layout_entry: Option<CacheEntry<LayoutOutput>>,
diff --git a/src/tree/layout.rs b/src/tree/layout.rs
index 90f070430..94c135766 100644
--- a/src/tree/layout.rs
+++ b/src/tree/layout.rs
@@ -6,6 +6,7 @@ use crate::util::sys::{f32_max, f32_min};
 
 /// Whether we are performing a full layout, or we merely need to size the node
 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
+#[cfg_attr(feature = "serde", derive(Serialize))]
 pub enum RunMode {
     /// A full layout for this node and all children should be computed
     PerformLayout,
@@ -18,6 +19,7 @@ pub enum RunMode {
 
 /// Whether styles should be taken into account when computing size
 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
+#[cfg_attr(feature = "serde", derive(Serialize))]
 pub enum SizingMode {
     /// Only content contributions should be taken into account
     ContentSize,
@@ -27,6 +29,7 @@ pub enum SizingMode {
 
 /// A set of margins that are available for collapsing with for block layout's margin collapsing
 #[derive(Copy, Clone, Debug, PartialEq)]
+#[cfg_attr(feature = "serde", derive(Serialize))]
 pub struct CollapsibleMarginSet {
     /// The largest positive margin
     positive: f32,
@@ -73,6 +76,7 @@ impl CollapsibleMarginSet {
 
 /// An axis that layout algorithms can be requested to compute a size for
 #[derive(Debug, Copy, Clone)]
+#[cfg_attr(feature = "serde", derive(Serialize))]
 pub enum RequestedAxis {
     /// The horizontal axis
     Horizontal,
@@ -103,6 +107,7 @@ impl TryFrom<RequestedAxis> for AbsoluteAxis {
 
 /// A struct containing the inputs constraints/hints for laying out a node, which are passed in by the parent
 #[derive(Debug, Copy, Clone)]
+#[cfg_attr(feature = "serde", derive(Serialize))]
 pub struct LayoutInput {
     /// Whether we only need to know the Node's size, or whe
     pub run_mode: RunMode,
@@ -152,6 +157,7 @@ impl LayoutInput {
 /// If your node does not have a baseline (or you are unsure how to compute it), then simply return `Point::NONE`
 /// for the first_baselines field
 #[derive(Debug, Copy, Clone)]
+#[cfg_attr(feature = "serde", derive(Serialize))]
 pub struct LayoutOutput {
     /// The size of the node
     pub size: Size<f32>,
@@ -216,6 +222,7 @@ impl LayoutOutput {
 
 /// The final result of a layout algorithm for a single node.
 #[derive(Debug, Copy, Clone)]
+#[cfg_attr(feature = "serde", derive(Serialize))]
 pub struct Layout {
     /// The relative ordering of the node
     ///