An API is the public-facing interface through which a crate exposes usable operations and data while hiding implementation details. In Rust, module structure can remain deeply nested internally while re-exports provide shorter, stable names at the crate root. section 5.2.2
A well-shaped Rust API:
- Exposes the names users should call, such as tree_cover::enter or crate::DayKind. section 5.2.2
- Hides generic helpers and internal modules when users should not call them directly. section 5.2.2
- Uses visibility deliberately: private items hide implementation, while pub(crate) permits use within the crate without exposing it publicly. section 5.2.2
- Acts as a contract whose behavior should remain consistent during incremental refactoring. section 1.1 section 1.3
Re-exporting a public type
A crate can define DayKind inside day_kind but publish it at the crate root with `pub use crate::day_kind::DayKind;`. Other modules then write `use crate::DayKind;`, while callers use the shorter public name without depending on the internal module path. section 5.2.2
pub use crate::day_kind::DayKind;
This listing shows the compact re-export that creates a crate-root API name. section 5.2.2











































