Rust Module System in egui — Separate UI from Logic | GUI Tutorial

1views
00
0:52
T
Taught by Celeste AI - AI Coding Coach
View on YouTube
Description
Build a Contact Book organized with Rust file-based modules! Learn mod declarations, pub/pub use re-exports, crate:: paths, and how to split your egui app into src/models/ and src/ui/ directories. Student code: https://github.com/GoCelesteAI/egui_modules_project_structure/tree/main What You'll Learn: - mod declarations for file-based modules - pub visibility for structs, fields, and functions - pub use re-exports in mod.rs files - crate:: paths for cross-module imports - Directory-based modules with mod.rs (src/models/, src/ui/) - Separating data models from UI logic - Reusable UI functions (show_contact_list, show_contact_form) - SidePanel with selectable_label contact list - CentralPanel with detail view and add form - Grid layout for form fields Project Structure: src/ main.rs — mod declarations & entry point app.rs — MyApp struct & eframe::App impl models/ mod.rs — pub use re-exports contact.rs — Contact struct ui/ mod.rs — pub use re-exports contact_list.rs — selectable contact list contact_form.rs — add contact form Timestamps: 0:00 Intro 0:12 App Preview 0:22 What We're Building 0:54 Create Project & Cargo.toml 1:26 main.rs — Three mod Declarations 2:10 mkdir for Module Directories 2:16 models/contact.rs — Contact Struct 2:50 models/mod.rs — pub use Re-export 3:08 ui/contact_list.rs — Selectable List 4:18 ui/contact_form.rs — Add Contact Form 5:32 ui/mod.rs — pub use Re-exports 5:54 app.rs — crate:: Imports & MyApp Struct 7:10 impl App — SidePanel & CentralPanel 8:22 cargo build & Neo-tree Browse 8:48 App Demo 9:40 Recap 10:20 Next Episode Series: Learn egui in Neovim Part of a 36-episode series teaching Rust GUI development with egui, coded entirely in Neovim with Neo-tree. Tags: egui, rust, gui, modules, project structure, mod, pub use, crate, tutorial, neovim, contact book, file modules, code organization

Tags

eguirustguimodulesproject structuremodpub usecratetutorialneovimcontact bookfile modulescode organization
Back to tutorials

Duration

0:52

Published

March 16, 2026

Added to Codegiz

March 17, 2026

Open in YouTube