Section 7 of 25

Who may import whom

Contents

7.1. Inside a slice

File May import May not import
model.rs kit; the model of other slices, through their mod.rs anything with I/O, async, store, drivers
logic.rs model I/O, async, store, drivers, service
store.rs model, the store crate drivers, service, logic of other slices
service.rs model, logic, store.rs, drivers, the public API of other slices tauri, global state
actor/* model, logic, service, drivers tauri; and update.rs also no I/O
app/<slice>/dto.rs the slice's model and error type, IpcError service, store
app/<slice>/commands.rs the slice's public API, dto, AppState store, drivers, logic

7.2. Between slices

  • Only through mod.rs. Deep paths such as crate::run::logic::… from another slice are forbidden.
  • No cycles. If a needs b and b needs a, the shared piece becomes its own slice (usually a small model or a small service), and both depend on it.
  • Policy is a slice, not a command. If a budget check lives in a command, then every lower layer that needs it has to import upward. That is the most common cause of cycles in Tauri applications.

7.3. Why these particular lines

The import table is built so that the expensive things to test (I/O, async, processes) sit in as few files as possible, and the valuable things to test (decisions) sit in files that have none of them. A decision in logic.rs is tested with a plain #[test] in microseconds. The same decision buried in a command needs a window.