mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-18 07:48:02 +08:00
Improve backwards compatability robustness of serde-based document format
This commit is contained in:
@@ -21,7 +21,7 @@ pub enum TaggedValue {
|
||||
String(String),
|
||||
U32(u32),
|
||||
U64(u64),
|
||||
F32(f32),
|
||||
#[serde(alias = "F32")] // TODO: Eventually remove this alias (probably starting late 2024)
|
||||
F64(f64),
|
||||
Bool(bool),
|
||||
UVec2(UVec2),
|
||||
@@ -43,6 +43,7 @@ pub enum TaggedValue {
|
||||
Fill(graphene_core::vector::style::Fill),
|
||||
Stroke(graphene_core::vector::style::Stroke),
|
||||
F64Array4([f64; 4]),
|
||||
#[serde(alias = "VecF32")] // TODO: Eventually remove this alias (probably starting late 2024)
|
||||
VecF64(Vec<f64>),
|
||||
VecDVec2(Vec<DVec2>),
|
||||
RedGreenBlue(graphene_core::raster::RedGreenBlue),
|
||||
@@ -87,7 +88,6 @@ impl Hash for TaggedValue {
|
||||
Self::String(x) => x.hash(state),
|
||||
Self::U32(x) => x.hash(state),
|
||||
Self::U64(x) => x.hash(state),
|
||||
Self::F32(x) => x.to_bits().hash(state),
|
||||
Self::F64(x) => x.to_bits().hash(state),
|
||||
Self::Bool(x) => x.hash(state),
|
||||
Self::UVec2(x) => x.to_array().iter().for_each(|x| x.hash(state)),
|
||||
@@ -168,7 +168,6 @@ impl<'a> TaggedValue {
|
||||
TaggedValue::String(x) => Box::new(x),
|
||||
TaggedValue::U32(x) => Box::new(x),
|
||||
TaggedValue::U64(x) => Box::new(x),
|
||||
TaggedValue::F32(x) => Box::new(x),
|
||||
TaggedValue::F64(x) => Box::new(x),
|
||||
TaggedValue::Bool(x) => Box::new(x),
|
||||
TaggedValue::UVec2(x) => Box::new(x),
|
||||
@@ -232,7 +231,6 @@ impl<'a> TaggedValue {
|
||||
TaggedValue::String(x) => format!("\"{x}\""),
|
||||
TaggedValue::U32(x) => x.to_string() + "_u32",
|
||||
TaggedValue::U64(x) => x.to_string() + "_u64",
|
||||
TaggedValue::F32(x) => x.to_string() + "_f32",
|
||||
TaggedValue::F64(x) => x.to_string() + "_f64",
|
||||
TaggedValue::Bool(x) => x.to_string(),
|
||||
TaggedValue::BlendMode(x) => "BlendMode::".to_string() + &x.to_string(),
|
||||
@@ -247,7 +245,6 @@ impl<'a> TaggedValue {
|
||||
TaggedValue::String(_) => concrete!(String),
|
||||
TaggedValue::U32(_) => concrete!(u32),
|
||||
TaggedValue::U64(_) => concrete!(u64),
|
||||
TaggedValue::F32(_) => concrete!(f32),
|
||||
TaggedValue::F64(_) => concrete!(f64),
|
||||
TaggedValue::Bool(_) => concrete!(bool),
|
||||
TaggedValue::UVec2(_) => concrete!(UVec2),
|
||||
@@ -314,7 +311,6 @@ impl<'a> TaggedValue {
|
||||
x if x == TypeId::of::<String>() => Ok(TaggedValue::String(*downcast(input).unwrap())),
|
||||
x if x == TypeId::of::<u32>() => Ok(TaggedValue::U32(*downcast(input).unwrap())),
|
||||
x if x == TypeId::of::<u64>() => Ok(TaggedValue::U64(*downcast(input).unwrap())),
|
||||
x if x == TypeId::of::<f32>() => Ok(TaggedValue::F32(*downcast(input).unwrap())),
|
||||
x if x == TypeId::of::<f64>() => Ok(TaggedValue::F64(*downcast(input).unwrap())),
|
||||
x if x == TypeId::of::<bool>() => Ok(TaggedValue::Bool(*downcast(input).unwrap())),
|
||||
x if x == TypeId::of::<UVec2>() => Ok(TaggedValue::UVec2(*downcast(input).unwrap())),
|
||||
|
||||
Reference in New Issue
Block a user