refactor: move resource/IO root modules under io/

Relocate three root-level modules into io/, where they belong by concern:

- update_check.rs -> io/update_check.rs (its own doc-comment notes it
  mirrors how crate::io wraps blocking calls in async).
- patterns.rs, linetypes.rs -> io/ (standard resource catalogs parsed
  from asset files and populated into the document — IO-shaped work).

Fix the moved files' include_str! paths (one level deeper), add the
mod declarations to io/mod.rs, drop them from lib.rs/main.rs, and
re-point all crate:: references to crate::io::. No behavior change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Hakan Seven 2026-06-26 23:06:40 +03:00
commit 415dbe08d4
15 changed files with 18 additions and 21 deletions

View file

@ -1,5 +1,5 @@
use crate::command::CadCommand; use crate::command::CadCommand;
use crate::linetypes; use crate::io::linetypes;
use crate::modules::draw::modify::refedit::RefEditSession; use crate::modules::draw::modify::refedit::RefEditSession;
use crate::scene::pick::grip::GripEdit; use crate::scene::pick::grip::GripEdit;
use crate::scene::GripDef; use crate::scene::GripDef;

View file

@ -60,7 +60,7 @@ impl OpenCADStudio {
} else { } else {
lt.name.clone() lt.name.clone()
}; };
let art = crate::linetypes::extract_pattern(&lt.description); let art = crate::io::linetypes::extract_pattern(&lt.description);
ui::properties::LinetypeItem { name, art } ui::properties::LinetypeItem { name, art }
}) })
.collect(); .collect();

View file

@ -1476,7 +1476,7 @@ pub enum Message {
Noop, Noop,
/// GitHub releases API returned a result. `Some(version)` means a /// GitHub releases API returned a result. `Some(version)` means a
/// newer release exists; we open the update-notice window. /// newer release exists; we open the update-notice window.
UpdateCheckResult(Option<crate::update_check::UpdateInfo>), UpdateCheckResult(Option<crate::io::update_check::UpdateInfo>),
/// User dismissed the update-notice window. /// User dismissed the update-notice window.
UpdateNoticeClose, UpdateNoticeClose,
/// First-launch default-association prompt: user accepted — register this /// First-launch default-association prompt: user accepted — register this
@ -2072,7 +2072,7 @@ impl OpenCADStudio {
s.main_window = Some(id); s.main_window = Some(id);
let open_main = open_task.map(|_| Message::Noop); let open_main = open_task.map(|_| Message::Noop);
let check_update = Task::perform( let check_update = Task::perform(
crate::update_check::check_for_update(), crate::io::update_check::check_for_update(),
Message::UpdateCheckResult, Message::UpdateCheckResult,
); );
let focus_cmd = s.focus_cmd_input(); let focus_cmd = s.focus_cmd_input();

View file

@ -1,6 +1,6 @@
use super::helpers::{entity_type_key, entity_type_label, title_case_word}; use super::helpers::{entity_type_key, entity_type_label, title_case_word};
use super::{OpenCADStudio, VARIES_LABEL}; use super::{OpenCADStudio, VARIES_LABEL};
use crate::linetypes; use crate::io::linetypes;
use crate::scene::view::dispatch; use crate::scene::view::dispatch;
use crate::ui; use crate::ui;
use acadrust::{EntityType, Handle}; use acadrust::{EntityType, Handle};

View file

@ -341,7 +341,7 @@ pub(super) fn on_open_file(&mut self) -> Task<Message> {
self.tabs[i].scene.selected = rustc_hash::FxHashSet::default(); self.tabs[i].scene.selected = rustc_hash::FxHashSet::default();
self.tabs[i].scene.preview_wires = vec![]; self.tabs[i].scene.preview_wires = vec![];
self.tabs[i].scene.current_layout = "Model".to_string(); self.tabs[i].scene.current_layout = "Model".to_string();
crate::linetypes::populate_document(&mut self.tabs[i].scene.document); crate::io::linetypes::populate_document(&mut self.tabs[i].scene.document);
self.tabs[i].properties = PropertiesPanel::empty(); self.tabs[i].properties = PropertiesPanel::empty();
// Seed the current table / multileader style from the file's // Seed the current table / multileader style from the file's
// header so the ✓ marks the right one (text/dim/mline come from // header so the ✓ marks the right one (text/dim/mline come from

View file

@ -537,7 +537,7 @@ impl OpenCADStudio {
let i = self.active_tab; let i = self.active_tab;
self.push_undo_snapshot(i, "CLEAR"); self.push_undo_snapshot(i, "CLEAR");
self.tabs[i].scene.clear(); self.tabs[i].scene.clear();
crate::linetypes::populate_document(&mut self.tabs[i].scene.document); crate::io::linetypes::populate_document(&mut self.tabs[i].scene.document);
self.tabs[i].properties = PropertiesPanel::empty(); self.tabs[i].properties = PropertiesPanel::empty();
let doc_layers = self.tabs[i].scene.document.layers.clone(); let doc_layers = self.tabs[i].scene.document.layers.clone();
let vp_info = self.tabs[i].scene.viewport_list(); let vp_info = self.tabs[i].scene.viewport_list();
@ -2449,7 +2449,7 @@ impl OpenCADStudio {
Task::none() Task::none()
} }
Message::UpdateNoticeOpenRelease => { Message::UpdateNoticeOpenRelease => {
crate::sys::open_url(crate::update_check::RELEASES_PAGE); crate::sys::open_url(crate::io::update_check::RELEASES_PAGE);
self.close_active_modal(); self.close_active_modal();
Task::none() Task::none()
} }

View file

@ -69,7 +69,7 @@ pub fn complex_lt(name: &str) -> Option<&'static ComplexLt> {
.get(&name.to_ascii_uppercase()) .get(&name.to_ascii_uppercase())
} }
const LIN_SOURCE: &str = include_str!("../assets/linetypes/OpenCADStudio.lin"); const LIN_SOURCE: &str = include_str!("../../assets/linetypes/OpenCADStudio.lin");
// ── Pattern art extraction ──────────────────────────────────────────────── // ── Pattern art extraction ────────────────────────────────────────────────

View file

@ -11,6 +11,9 @@ pub mod print_to_printer;
pub mod step; pub mod step;
pub mod stl; pub mod stl;
pub mod xref; pub mod xref;
pub mod linetypes;
pub mod patterns;
pub mod update_check;
use crate::scene::DerivedCaches; use crate::scene::DerivedCaches;
use acadrust::entities::{Dimension, EntityType}; use acadrust::entities::{Dimension, EntityType};
@ -879,7 +882,7 @@ mod layer_roundtrip_tests {
// round-trip through `ext`, and return whether every one survived. // round-trip through `ext`, and return whether every one survived.
fn roundtrip_layers(ext: &str, count: usize) -> bool { fn roundtrip_layers(ext: &str, count: usize) -> bool {
let mut doc = CadDocument::new(); let mut doc = CadDocument::new();
crate::linetypes::populate_document(&mut doc); crate::io::linetypes::populate_document(&mut doc);
let names: Vec<String> = (0..count).map(|n| format!("Layer{}", n + 1)).collect(); let names: Vec<String> = (0..count).map(|n| format!("Layer{}", n + 1)).collect();
for name in &names { for name in &names {
let mut dl = DocLayer::new(name); let mut dl = DocLayer::new(name);

View file

@ -8,7 +8,7 @@
use std::sync::OnceLock; use std::sync::OnceLock;
const PAT_SRC: &str = include_str!("../assets/patterns/OpenCADStudio.pat"); const PAT_SRC: &str = include_str!("../../assets/patterns/OpenCADStudio.pat");
// ── Public types ────────────────────────────────────────────────────────── // ── Public types ──────────────────────────────────────────────────────────

View file

@ -6,13 +6,10 @@ pub mod cli;
pub mod command; pub mod command;
pub mod entities; pub mod entities;
pub mod io; pub mod io;
pub mod linetypes;
pub mod modules; pub mod modules;
pub mod plugin; pub mod plugin;
pub mod patterns;
pub mod scene; pub mod scene;
pub mod snap; pub mod snap;
pub mod ui; pub mod ui;
pub mod par; pub mod par;
pub mod sys; pub mod sys;
pub mod update_check;

View file

@ -10,16 +10,13 @@ mod cli;
mod command; mod command;
mod entities; mod entities;
mod io; mod io;
mod linetypes;
mod modules; mod modules;
mod plugin; mod plugin;
mod patterns;
mod scene; mod scene;
mod snap; mod snap;
mod ui; mod ui;
mod par; mod par;
mod sys; mod sys;
mod update_check;
fn main() -> iced::Result { fn main() -> iced::Result {
// Web (wasm) uses the single-window entry; native uses the multi-window // Web (wasm) uses the single-window entry; native uses the multi-window

View file

@ -6,7 +6,7 @@
use std::sync::OnceLock; use std::sync::OnceLock;
use crate::patterns::PatLineDef; use crate::io::patterns::PatLineDef;
use crate::scene::model::hatch_model::{HatchPattern, PatFamily}; use crate::scene::model::hatch_model::{HatchPattern, PatFamily};
use acadrust::entities::{HatchPattern as DxfPattern, HatchPatternLine}; use acadrust::entities::{HatchPattern as DxfPattern, HatchPatternLine};
use acadrust::types::Vector2; use acadrust::types::Vector2;
@ -65,7 +65,7 @@ fn build_catalog() -> Vec<PatternEntry> {
pat_lines: vec![], pat_lines: vec![],
}]; }];
for def in crate::patterns::catalog() { for def in crate::io::patterns::catalog() {
entries.push(PatternEntry { entries.push(PatternEntry {
name: def.name.clone(), name: def.name.clone(),
description: def.description.clone(), description: def.description.clone(),

View file

@ -665,7 +665,7 @@ pub(crate) fn tessellate_entity(
// linetype assigned, so we only consult the first wire here — multi-wire // linetype assigned, so we only consult the first wire here — multi-wire
// returns come exclusively from MTEXT colour splits which can't trigger // returns come exclusively from MTEXT colour splits which can't trigger
// this path. // this path.
if let Some(clt) = crate::linetypes::complex_lt(lt_name) { if let Some(clt) = crate::io::linetypes::complex_lt(lt_name) {
if let Some(base) = bases.first() { if let Some(base) = bases.first() {
let mut wires = text::complex_lt::apply_along( let mut wires = text::complex_lt::apply_along(
&base.name, &base.name,

View file

@ -7,7 +7,7 @@
//! Shape X → along the linetype direction; Shape Y → perpendicular in XZ. //! Shape X → along the linetype direction; Shape Y → perpendicular in XZ.
use crate::entities::text_support::resolve_dxf_special_chars; use crate::entities::text_support::resolve_dxf_special_chars;
use crate::linetypes::{ComplexLt, LtSegment}; use crate::io::linetypes::{ComplexLt, LtSegment};
use crate::scene::text::lff; use crate::scene::text::lff;
use crate::scene::model::wire_model::WireModel; use crate::scene::model::wire_model::WireModel;