Skip to content

Commit

Permalink
port: Remove references to ExportFormat.
Browse files Browse the repository at this point in the history
  • Loading branch information
kpreid committed Aug 22, 2024
1 parent 3f09672 commit 4b6eef2
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 14 deletions.
10 changes: 5 additions & 5 deletions all-is-cubes-desktop/src/bin/all-is-cubes/command_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,20 +348,20 @@ impl FromStr for SpaceSizeArg {
pub fn determine_record_format(
output_path: &std::path::Path,
) -> Result<RecordFormat, &'static str> {
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)),
_ => {}
}
}
Expand Down
6 changes: 3 additions & 3 deletions all-is-cubes-desktop/src/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -48,7 +48,7 @@ enum RecorderInner {
Mesh(write_gltf::MeshRecorder),
Export {
executor: Arc<crate::Executor>,
export_format: ExportFormat,
export_format: Format,
/// Becomes `None` when export has been performed
export_set: Option<ExportSet>,
options: RecordOptions,
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion all-is-cubes-desktop/src/record/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion all-is-cubes-port/src/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl all_is_cubes::save::WhenceUniverse for PortWhence {
universe: &Universe,
progress: YieldProgress,
) -> BoxFuture<'static, Result<(), Box<dyn std::error::Error + Send + Sync>>> {
use crate::{ExportSet};
use crate::ExportSet;

let source = ExportSet::all_of_universe(universe);
let save_format = self.format;
Expand Down
3 changes: 0 additions & 3 deletions all-is-cubes-port/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test-renderers/tests/gltf-render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 4b6eef2

Please sign in to comment.