mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
Migrate remaining node graph data types from Vec to Table (#4067)
* Move Vec<String> to Table<String> * Remove old VecDVec2 * Move Vec<u8> to Table<u8> * Move Vec<f64> to Table<f64> * Move [f64; 4] to Table<f64> * Move Vec<NodeId> to Table<NodeId> * Tidy up the TaggedValue variants * Move Vec<BrushStroke> to Table<BrushStroke> * Add missing type implementations * Fix tests ---------
This commit is contained in:
@@ -87,3 +87,21 @@ pub fn migrate_color<'de, D: serde::Deserializer<'de>>(deserializer: D) -> Resul
|
||||
ColorFormat::ColorTable(color_table) => color_table,
|
||||
})
|
||||
}
|
||||
|
||||
// TODO: Eventually remove this migration document upgrade code
|
||||
pub fn migrate_vec_f64_to_table<'de, D: serde::Deserializer<'de>>(deserializer: D) -> Result<crate::table::Table<f64>, D::Error> {
|
||||
use crate::table::{Table, TableRow};
|
||||
use serde::Deserialize;
|
||||
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[cfg_attr(feature = "serde", serde(untagged))]
|
||||
enum F64TableFormat {
|
||||
VecF64(Vec<f64>),
|
||||
F64Table(Table<f64>),
|
||||
}
|
||||
|
||||
Ok(match F64TableFormat::deserialize(deserializer)? {
|
||||
F64TableFormat::VecF64(values) => values.into_iter().map(TableRow::new_from_element).collect(),
|
||||
F64TableFormat::F64Table(table) => table,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user