From 4b6eef2117a23d8bee6f8cf36911a446573364a4 Mon Sep 17 00:00:00 2001 From: Kevin Reid Date: Wed, 21 Aug 2024 16:09:42 -0700 Subject: [PATCH] port: Remove references to `ExportFormat`. --- .../src/bin/all-is-cubes/command_options.rs | 10 +++++----- all-is-cubes-desktop/src/record.rs | 6 +++--- all-is-cubes-desktop/src/record/options.rs | 2 +- all-is-cubes-port/src/import.rs | 2 +- all-is-cubes-port/src/lib.rs | 3 --- test-renderers/tests/gltf-render.rs | 2 +- 6 files changed, 11 insertions(+), 14 deletions(-) diff --git a/all-is-cubes-desktop/src/bin/all-is-cubes/command_options.rs b/all-is-cubes-desktop/src/bin/all-is-cubes/command_options.rs index c261e96cf..904a35b88 100644 --- a/all-is-cubes-desktop/src/bin/all-is-cubes/command_options.rs +++ b/all-is-cubes-desktop/src/bin/all-is-cubes/command_options.rs @@ -348,20 +348,20 @@ impl FromStr for SpaceSizeArg { pub fn determine_record_format( output_path: &std::path::Path, ) -> Result { - use all_is_cubes_port::ExportFormat; + use all_is_cubes_port::Format; if let Some(extension) = output_path.extension() { match extension.to_str() { // When updating this match, also update the docs for output_file! - // TODO: RecordFormat and ExportFormat should be merged? + // TODO: RecordFormat and port::Format should be merged? Some("alliscubesjson" | "ALLISCUBESJSON") => { - return Ok(RecordFormat::Export(ExportFormat::AicJson)) + return Ok(RecordFormat::Export(Format::AicJson)) } Some("png" | "PNG") => return Ok(RecordFormat::PngOrApng), Some("apng" | "APNG") => return Ok(RecordFormat::PngOrApng), Some("gltf" | "GLTF") => return Ok(RecordFormat::Gltf), - Some("stl" | "STL") => return Ok(RecordFormat::Export(ExportFormat::Stl)), - Some("vox" | "VOX") => return Ok(RecordFormat::Export(ExportFormat::DotVox)), + Some("stl" | "STL") => return Ok(RecordFormat::Export(Format::Stl)), + Some("vox" | "VOX") => return Ok(RecordFormat::Export(Format::DotVox)), _ => {} } } diff --git a/all-is-cubes-desktop/src/record.rs b/all-is-cubes-desktop/src/record.rs index 8cfd1b34f..4a88d2f6e 100644 --- a/all-is-cubes-desktop/src/record.rs +++ b/all-is-cubes-desktop/src/record.rs @@ -10,7 +10,7 @@ use anyhow::Context; use all_is_cubes::listen::{self, Listen as _, ListenableSource}; use all_is_cubes::universe::Universe; use all_is_cubes_port::gltf::{GltfDataDestination, GltfWriter}; -use all_is_cubes_port::{ExportFormat, ExportSet}; +use all_is_cubes_port::{ExportSet, Format}; use all_is_cubes_render::camera::StandardCameras; use all_is_cubes_render::raytracer::RtRenderer; use all_is_cubes_render::Flaws; @@ -48,7 +48,7 @@ enum RecorderInner { Mesh(write_gltf::MeshRecorder), Export { executor: Arc, - export_format: ExportFormat, + export_format: Format, /// Becomes `None` when export has been performed export_set: Option, options: RecordOptions, @@ -159,7 +159,7 @@ impl Recorder { // TODO: better rule than this special case. AicJson doesn't strictly require // all of the universe, but it does require the transitive closure, and this is the // easiest way to proceed for now. - let export_set = if options.save_all || export_format == ExportFormat::AicJson { + let export_set = if options.save_all || export_format == Format::AicJson { ExportSet::all_of_universe(universe) } else { ExportSet::from_spaces(vec![cameras.world_space().snapshot().ok_or_else( diff --git a/all-is-cubes-desktop/src/record/options.rs b/all-is-cubes-desktop/src/record/options.rs index 214e2080d..9441148f3 100644 --- a/all-is-cubes-desktop/src/record/options.rs +++ b/all-is-cubes-desktop/src/record/options.rs @@ -39,7 +39,7 @@ pub enum RecordFormat { Gltf, /// Any [`all_is_cubes_port`] export format may be written via the recording feature. - Export(all_is_cubes_port::ExportFormat), + Export(all_is_cubes_port::Format), } impl RecordOptions { diff --git a/all-is-cubes-port/src/import.rs b/all-is-cubes-port/src/import.rs index a43093ed2..3ce9b1a62 100644 --- a/all-is-cubes-port/src/import.rs +++ b/all-is-cubes-port/src/import.rs @@ -119,7 +119,7 @@ impl all_is_cubes::save::WhenceUniverse for PortWhence { universe: &Universe, progress: YieldProgress, ) -> BoxFuture<'static, Result<(), Box>> { - use crate::{ExportSet}; + use crate::ExportSet; let source = ExportSet::all_of_universe(universe); let save_format = self.format; diff --git a/all-is-cubes-port/src/lib.rs b/all-is-cubes-port/src/lib.rs index 9bef7cf41..530cb64a9 100644 --- a/all-is-cubes-port/src/lib.rs +++ b/all-is-cubes-port/src/lib.rs @@ -45,9 +45,6 @@ mod stl; #[cfg(test)] mod tests; -// TODO: Remove this type alias. -pub type ExportFormat = Format; - /// File formats that All is Cubes data can be exported to or imported from. /// /// Note that if some feature flags are disabled, this library may not be in fact able to diff --git a/test-renderers/tests/gltf-render.rs b/test-renderers/tests/gltf-render.rs index b80fdb928..4d536e7e4 100644 --- a/test-renderers/tests/gltf-render.rs +++ b/test-renderers/tests/gltf-render.rs @@ -236,7 +236,7 @@ impl HeadlessRenderer for GltfRend3Renderer { let progress = all_is_cubes::util::yield_progress_for_testing(); port::export_to_path( progress, - port::ExportFormat::Gltf, + port::Format::Gltf, port::ExportSet::from_spaces( world_space .into_iter()