Skip to content

refactor: enforce mutability guidelines on NativeEngine FFI calls #32

Description

@rvoidex7

Description

Currently, mutating methods on the NativeEngine struct (such as update, process_input, equip_item, and unequip_item in ffi.rs) accept &self (immutable references) despite mutating the state of the underlying C# game core through the FFI boundary.

While this currently works because the simulation loop is single-threaded, it bypasses Rust's aliasing guarantees and presents a concurrency risk if multi-threading is introduced.

Proposed Changes

  1. Change FFI method signatures in ffi.rs to take &mut self instead of &self.
  2. Update callers in main.rs (e.g. declaring let mut simulation = ... instead of let simulation = ...).
  3. Update handle_key_event signature to accept simulation: &mut NativeEngine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions