一键导入
api-design
Public API Design guidance for Fortress Rollback. Use when Designing public APIs, checking semver compliance, reviewing breaking changes.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Public API Design guidance for Fortress Rollback. Use when Designing public APIs, checking semver compliance, reviewing breaking changes.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Crate Publishing guidance for Fortress Rollback. Use when Publishing to crates.io, version bumps, release checklist.
Changelog Practices guidance for Fortress Rollback. Use when Writing CHANGELOG entries, deciding what to document.
Design Decision Log Pattern guidance for Fortress Rollback. Use when Architectural decisions, design alternatives, superseding prior choices.
Repository-wide engineering policy and project context for Fortress Rollback. Use when implementing, diagnosing, reviewing, testing, documenting, or releasing changes in this repository.
GitHub Actions Best Practices guidance for Fortress Rollback. Use when Writing GitHub Actions workflows, CI debugging, actionlint, caching.
Workspace Organization guidance for Fortress Rollback. Use when Organizing workspace, splitting crates, module structure decisions.
| name | api-design |
| description | Public API Design guidance for Fortress Rollback. Use when Designing public APIs, checking semver compliance, reviewing breaking changes. |
pub(crate), private fields#[non_exhaustive] judiciously| Level | When |
|---|---|
fn (private) | Default -- accessible only in module |
pub(crate) | Crate-internal helpers |
pub(super) | Parent module helpers |
pub | Intentional public API -- forever commitment |
Never expose struct fields directly unless fundamental to meaning. Use accessor methods.
#[non_exhaustive]| Use on | When |
|---|---|
| Error enums | May gain variants in minor releases |
| Config structs | May gain fields |
| Avoid on | Fixed-set enums where exhaustive matching catches bugs |
Frame, PlayerHandle, Port)Clone, Copy, Debug, PartialEq, Eq, Hashpub mod session {
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum CreateError { /* ... */ }
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum AdvanceError { /* ... */ }
}
/// # Errors
///
/// Returns [`CreateError::InvalidConfig`] if config.max_players is zero.
/// Returns [`CreateError::NetworkBind`] if UDP socket cannot bind.
pub fn create(config: SessionConfig) -> Result<Session, CreateError> { /* ... */ }
#![warn(missing_docs)]
#![warn(rustdoc::broken_intra_doc_links)]
[Session::rollback_count]pub use bytes::{Bytes, BytesMut}; // re-export dep types in public API
pub mod prelude; // common imports for convenience
pub type Result<T, E = Error> = std::result::Result<T, E>; // result alias
Result alias hazard: Use distinctive names (FortressResult) to avoid shadowing std::result::Result.
+ Send + Sync only with sync feature)[features]
default = []
serde = ["dep:serde"]
async = ["dep:tokio"]
full = ["serde", "async"]
#[non_exhaustive])cargo install cargo-semver-checks
cargo semver-checks check-release
pub(crate) for internal items?#[non_exhaustive] only where catch-all is acceptable?# Errors section in docs?#![warn(missing_docs)] enabled?cargo semver-checks run?| Anti-Pattern | Solution |
|---|---|
| Public fields | Private fields + accessors |
| Exposing dep types | Newtype wrappers |
| One mega error type | Scoped error types |
| Complex trait bounds | Minimal bounds |
Missing #[non_exhaustive] on errors | Add annotation |
#[non_exhaustive] on fixed enums | Keep exhaustive |
| Missing re-exports | Re-export public deps |
| Breaking changes in minor | cargo-semver-checks |