#[platform_mod]Expand description
Declares a platform-dependent module backed by OS-specific source files.
This attribute simplifies the management of platform-specific code modules. Instead of manually
writing multiple #[cfg(...)] mod ...; blocks, you define a single logical module name.
The macro expects corresponding files (e.g., linux.rs, windows.rs) to exist in the same directory.
§Options
Same as sys_function: include(...) and exclude(...) determine which platform modules are generated.
§Visibility Behavior
This macro enforces a strict separation between internal convenience and external access:
- The Module (External): The actual platform module (e.g.,
mod linux;) inherits the visibility you declared. If you writepub mod driver;, the generatedmod linux;will be public. - The Alias (Internal): The logical name you specified (e.g.,
driver) is generated as a private use-alias.
Why? This ensures that external consumers of your crate must be explicit about the platform they are accessing
(e.g., my_crate::linux::MyStruct), while allowing you to use the generic name (e.g., driver::MyStruct)
conveniently within your own code.