Skip to main content

modelio/
utility.rs

1use std::path::Path;
2
3use crate::error::Result;
4use crate::ffi;
5use crate::util::path_to_c_string;
6
7#[derive(Debug, Clone, Copy, Default)]
8/// Wraps the corresponding Model I/O utility counterpart.
9pub struct Utility;
10
11impl Utility {
12    /// Calls the corresponding Model I/O method on the wrapped Model I/O utility counterpart.
13    pub fn convert_to_usdz(
14        input_url: impl AsRef<Path>,
15        output_url: impl AsRef<Path>,
16    ) -> Result<()> {
17        let input_url = path_to_c_string(input_url.as_ref())?;
18        let output_url = path_to_c_string(output_url.as_ref())?;
19        let mut out_error = std::ptr::null_mut();
20        // SAFETY: The unsafe operation is valid in this context.
21        let status = unsafe {
22            ffi::mdl_utility_convert_to_usdz(
23                input_url.as_ptr(),
24                output_url.as_ptr(),
25                &mut out_error,
26            )
27        };
28        crate::util::status_result(status, out_error)
29    }
30}