# Port [meshoptimizer] to safe, panic-free Rust **Goal: Port the functionality of [meshoptimizer] to an ergonomic pure Rust library that is fully safe and panic-free on arbitrary user input** Previous/related work: - [meshopt-rs] previous port but seems dead/unmaintained. Could be a start. Alternatives - Use existing [meshopt] Rust layer, which wraps the C++ [meshoptimizer] library, but compile and use it in WASM to sandbox it and guarantee to keep it safe. - Pros: - Easier & faster to do - Cons: - More custom host, less useful for others - Less ergonomic to use as [meshopt] lacks features and is not fully maintained - Harder to outsource the work, has to be done inside team ## Requirements ### Environment - Support Rust 1.58+ or "latest stable" - Support Rust targets - aarch64-apple-darwin - aarch64-linux-android - x86_64-apple-darwin - x86_64-pc-windows-msvc - x86_64-unknown-linux-gnu - x86_64-unknown-linux-musl - wasm32-unknown-unknown - wasm32-wasi ### Features - Support all functionality that [meshoptimizer] supports - TBD: Determine which functionality we use and want to prioritize first, some other parts could be optional ### Code - No or very minimal dependencies - No usage of proc macros - No usage of `build.rs` in the crate itself - No panics on any user input, handles all possible errors with user input and returns structured enum errors to caller with context of error. - Crate uses [Embark standard Clippy lints v0.5](https://github.com/EmbarkStudios/rust-ecosystem/issues/59) (or later) - Crate uses [safety lints](#safety-lints) - Crate can be built & tested without any unsafe code (`#[forbid(unsafe_code)`) - Crate can be built and run in `wasm32-unknown-unknown` and `wasm32-wasi` target - Good user documentation of crate for docs.rs ### Testing - Has automatic test suite with that verifies output of crate and original C library is identical across set of tests - Repository is setup to use CI through GitHub actions and build and run full test suite on Mac, Windows, Linux and wasm32-wasi on every PR ### Project - Project is in public GitHub repository - Project & repository uses and follows the [Contributor Covenant ](https://www.contributor-covenant.org/) Code of Conduct. - Project & crate uses permissive licenses: `MIT OR Apache-2.0` - Crate is published on crates.io - Rust semantic versioning is followed, with tagged release in GitHub project - Optional - Have an optional `performance` feature that does use documented and verified-to-be-sound `unsafe` blocks for improved performance. Use lints `unsafe_op_in_unsafe_fn` and `undocumented_unsafe_blocks` TBD: - Require full ownership of project and it being on EmbarkStudios github org and crates.io org? Likely ## Acceptance criterias - Crate follows all of the [requirements](#requirements) ## Safety lints We use these additional Clippy lints for code handling arbitrary user data to make sure it is safe and handles all errors and not panic. ```rust #[deny( clippy::unimplemented, clippy::expect_used, clippy::unwrap_used, clippy::ok_expect, clippy::integer_division, clippy::indexing_slicing, clippy::mem_forget )] ``` [meshopt]: https://github.com/gwihlidal/meshopt-rs [meshopt-rs]: https://github.com/yzsolt/meshopt-rs [meshoptimizer]: https://github.com/zeux/meshoptimizer