MudEngine Part 4: Single-Player Dioxus GUI
Wire up the module skeleton
Create the files that declare the module structure. main.rs becomes a thin entry point — it declares the two modules and launches the App component (which we will define in src/components/app.rs in a moment).
Replace the auto-generated src/main.rs with:
mod components; mod game; use crate::components::app::App; fn main() { dioxus::launch(App); }
Create the module declaration files. Rust looks up a module named game in src/game.rs — this is the modern layout, where a directory module's root file sits next to the directory instead of inside it as mod.rs. From game.rs, Rust finds the module's own submodules in the sibling src/game/ directory.
src/components/ is the one exception: in Part 5 dx components add writes its library declarations into src/components/mod.rs, so that directory keeps the classic mod.rs name.
src/game.rs— declares the game-logic submodulessrc/components/mod.rs— declares every Dioxus component file
pub mod world;
pub mod app; pub mod world_grid;
mod game;andmod components;tell Rust about our two top-level modules.pub mod world;(insrc/game.rs) exposesgame::world.pub mod app; pub mod world_grid;(incomponents/mod.rs) exposecomponents::appandcomponents::world_grid.
The pub keyword matters: a component in one file must be visible to a component in another file. App is used by main.rs (dioxus::launch(App)), and WorldGrid is used by App — so both need to be pub. We will see the same pub on the component functions themselves in the next steps.