From 02e9bde82539c5a74a2c4e27c62fa23005731f8a Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Mon, 27 Apr 2026 10:53:20 -0700 Subject: [PATCH] cleanup --- rust/pspp/src/spv/read/graph.rs | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/rust/pspp/src/spv/read/graph.rs b/rust/pspp/src/spv/read/graph.rs index bdd1f5778c..0e23359412 100644 --- a/rust/pspp/src/spv/read/graph.rs +++ b/rust/pspp/src/spv/read/graph.rs @@ -187,7 +187,7 @@ impl Locations for Visualization { } impl Visualization { - pub fn decode_series( + fn decode_series( &self, locale: &'static Locale<'static>, data: DataSources, @@ -473,7 +473,7 @@ impl Visualization { Ok(elements) } - pub fn delimited_file_source(&self) -> Option<&DelimitedFileSource> { + fn delimited_file_source(&self) -> Option<&DelimitedFileSource> { self.children .iter() .find_map(|child| child.delimited_file_source()) @@ -1024,7 +1024,7 @@ impl FontMetrics { } #[derive(Clone, Debug)] -pub struct SeriesValue { +struct SeriesValue { value: Datum, label: Option, } @@ -1042,15 +1042,15 @@ where } #[derive(Clone)] -pub struct Series { +struct Series { pub name: String, label: Option, short_label: Option, weight: bool, key: bool, categorical: bool, - pub values: Vec, - pub unique_values: Vec, + values: Vec, + unique_values: Vec, formatter: Formatter, } @@ -1167,7 +1167,7 @@ impl VisChild { #[derive(Deserialize, Debug)] #[serde(rename_all = "camelCase")] -pub struct DelimitedFileSource { +struct DelimitedFileSource { /// Source name. #[serde(rename = "@id")] pub id: String, @@ -1270,7 +1270,7 @@ impl EmbeddedSource { #[derive(Deserialize, Debug, Default)] #[serde(rename_all = "camelCase")] -pub enum DelimitedFileSourceMissing { +enum DelimitedFileSourceMissing { #[default] Pairwise, } @@ -2292,7 +2292,7 @@ enum Mdy { Year, } -pub struct NotMdy; +struct NotMdy; impl TryFrom<&Item<'_>> for Mdy { type Error = NotMdy; @@ -4463,7 +4463,7 @@ impl Span { } #[derive(Copy, Clone, Debug, PartialEq)] -pub struct Scaling { +struct Scaling { /// Smallest tick. pub base: f64, @@ -4706,7 +4706,7 @@ impl<'a> Iterator for FacetIterator<'a> { impl<'a> ExactSizeIterator for FacetIterator<'a> {} -pub struct SemicolonSplit<'a>(Option<&'a str>); +struct SemicolonSplit<'a>(Option<&'a str>); impl<'a> SemicolonSplit<'a> { fn new(s: &'a str) -> Self { @@ -4846,6 +4846,8 @@ impl crate::output::Graph { return Cow::Borrowed(self); } + // Copy the input to the output, except for parsing data out of all the + // `embeddedSource` elements and replacing them with `userSource` stubs. let mut data = IndexMap::new(); let mut reader = Reader::from_reader(self.xml.as_slice()); let mut writer = Writer::new(Vec::new()); @@ -4899,14 +4901,17 @@ impl crate::output::Graph { } } - if data.is_empty() { - Cow::Borrowed(self) - } else { + if !data.is_empty() { + // Turn the parsed data into a `.bin` member. Cow::Owned(crate::output::Graph { xml: writer.into_inner(), data: Some(DataSources(data).to_legacy_bin()), csv: self.csv.clone(), }) + } else { + // We didn't find any `embeddedSource` elements, so stick with what + // we had. + Cow::Borrowed(self) } } -- 2.47.3