remove dead code
authorBen Pfaff <blp@cs.stanford.edu>
Thu, 15 May 2025 23:57:09 +0000 (16:57 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Thu, 15 May 2025 23:57:09 +0000 (16:57 -0700)
rust/pspp/src/output/spv.rs

index c3293f24794ef2bc0352ddb76dd5f81c3ad3ce2a..11391e5eb38ad9257cc824f08ac979a2f4b4cd55 100644 (file)
@@ -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<String>,
-    show: bool,
-    label: Label,
-    children: Vec<Child>,
-}
-
-impl Heading {
-    fn emit<W>(&self, writer: &mut XmlWriter<W>) -> 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<Heading>),
-}
-
-impl Child {
-    fn emit<W>(&self, writer: &mut XmlWriter<W>) -> 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<I>,
@@ -582,110 +537,6 @@ where
     }
 }
 
-struct Container {
-    page_break_before: bool,
-    label: Label,
-    show: bool,
-    command_name: Option<String>,
-    content: Content,
-}
-
-impl Container {
-    fn emit<W>(&self, writer: &mut XmlWriter<W>) -> 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<W>(&self, writer: &mut XmlWriter<W>) -> IoResult<()>
-    where
-        W: Write,
-    {
-        writer
-            .create_element("label")
-            .write_text_content(BytesText::new(&self.0))?;
-        Ok(())
-    }
-}
-
-enum Content {
-    Table(Table),
-}
-
-impl Content {
-    fn emit<W>(&self, writer: &mut XmlWriter<W>, 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<W>,
-        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<W>(&self, writer: &mut XmlWriter<W>, 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}");
-    }
-}