From 25a5e6bcf62b920a9b6a9de88837a6f8f56c5bc0 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Thu, 15 May 2025 16:57:09 -0700 Subject: [PATCH] remove dead code --- rust/pspp/src/output/spv.rs | 172 +----------------------------------- 1 file changed, 1 insertion(+), 171 deletions(-) diff --git a/rust/pspp/src/output/spv.rs b/rust/pspp/src/output/spv.rs index c3293f2479..11391e5eb3 100644 --- a/rust/pspp/src/output/spv.rs +++ b/rust/pspp/src/output/spv.rs @@ -2,7 +2,7 @@ use core::f64; use std::{ borrow::Cow, fmt::Write as _, - io::{Cursor, Result as IoResult, Seek, Write}, + io::{Cursor, Seek, Write}, iter::{repeat, repeat_n}, sync::Arc, }; @@ -15,7 +15,6 @@ use quick_xml::{ writer::Writer as XmlWriter, ElementWriter, }; -use serde::Serialize; use smallstr::SmallString; use zip::{result::ZipResult, write::SimpleFileOptions, ZipWriter}; @@ -524,50 +523,6 @@ where } } -struct Heading { - command_name: Option, - show: bool, - label: Label, - children: Vec, -} - -impl Heading { - fn emit(&self, writer: &mut XmlWriter) -> IoResult<()> - where - W: Write, - { - let mut element = writer.create_element("heading"); - if let Some(command_name) = &self.command_name { - element = element.with_attribute(("commandName", command_name.as_str())); - } - if !self.show { - element = element.with_attribute(("visibility", "collapsed")); - } - element.write_inner_content(|writer| { - self.label.emit(writer)?; - Ok(()) - })?; - Ok(()) - } -} - -enum Child { - Container(Container), - Heading(Box), -} - -impl Child { - fn emit(&self, writer: &mut XmlWriter) -> IoResult<()> - where - W: Write, - { - match self { - Child::Container(container) => container.emit(writer), - Child::Heading(heading) => heading.emit(writer), - } - } -} - fn maybe_with_attribute<'a, 'b, W, I>( element: ElementWriter<'a, W>, attr: Option, @@ -582,110 +537,6 @@ where } } -struct Container { - page_break_before: bool, - label: Label, - show: bool, - command_name: Option, - content: Content, -} - -impl Container { - fn emit(&self, writer: &mut XmlWriter) -> IoResult<()> - where - W: Write, - { - let mut element = writer - .create_element("container") - .with_attribute(("visibility", if self.show { "visible" } else { "hidden" })); - if self.page_break_before { - element = element.with_attribute(("page-break-before", "always")); - } - element.write_inner_content(|writer| { - self.label.emit(writer)?; - self.content - .emit(writer, self.command_name.as_ref().map(|name| name.as_str()))?; - Ok(()) - })?; - Ok(()) - } -} - -struct Label(String); - -impl Label { - fn emit(&self, writer: &mut XmlWriter) -> IoResult<()> - where - W: Write, - { - writer - .create_element("label") - .write_text_content(BytesText::new(&self.0))?; - Ok(()) - } -} - -enum Content { - Table(Table), -} - -impl Content { - fn emit(&self, writer: &mut XmlWriter, command_name: Option<&str>) -> IoResult<()> - where - W: Write, - { - match self { - Content::Table(table) => table.emit(writer, command_name), - } - } - - fn element<'a, W>( - writer: &'a mut XmlWriter, - name: &'static str, - command_name: Option<&str>, - ) -> ElementWriter<'a, W> { - let element = writer.create_element(name); - let element = maybe_with_attribute( - element, - command_name.map(|command_name| ("commandName", command_name)), - ); - element - } -} - -struct Table { - table_properties: Option<()>, - - table_structure: TableStructure, - table_id: u64, - subtype: String, -} - -impl Table { - fn emit(&self, writer: &mut XmlWriter, command_name: Option<&str>) -> IoResult<()> - where - W: Write, - { - Content::element(writer, "vtb:table", command_name) - .with_attribute(("type", "table")) - .with_attribute(("tableId", Cow::from(format!("{}", self.table_id)))) - .with_attribute(("subtype", self.subtype.as_str())) - .write_inner_content(|w| { - w.create_element("vtb:TableStructure") - .write_inner_content(|w| { - w.create_element("vtb:dataPath") - .write_text_content(BytesText::new(&light_table_name(self.table_id)))?; - Ok(()) - })?; - Ok(()) - })?; - Ok(()) - } -} - -#[derive(Serialize)] -struct TableStructure; - impl BinWrite for Dimension { type Args<'a> = (usize, u8); @@ -1384,24 +1235,3 @@ impl BinWrite for Value { Ok(()) } } - -#[cfg(test)] -mod test { - use crate::output::spv::Heading; - - #[test] - fn serialize() { - let heading = Heading { - command_name: Some("foo".into()), - show: false, - label: super::Label("bar".into()), - children: Vec::new(), - }; - let mut output = Vec::new(); - let mut writer = quick_xml::writer::Writer::new(&mut output); - heading.emit(&mut writer).unwrap(); - drop(writer); - let output = String::from_utf8(output).unwrap(); - println!("{output}"); - } -} -- 2.30.2