- Status: Example
- Specification:
../specs/example-retry-policy.md
This is a sample implementation plan, not active work. Replace or remove it when generating a real project from this template.
Add the specified typed retry policy through small red-green-refactor steps, without adding a runtime, timers, or new dependencies.
Files: src/retry/mod.rs, src/retry/types.rs, src/retry/test.rs
-
Create the module skeleton and a failing test for zero attempts:
#[test] fn rejects_zero_max_attempts() { assert_eq!( RetryPolicy::new(0).unwrap_err(), Error::ZeroMaxAttempts, ); }
-
Add
Error::ZeroMaxAttemptsinsrc/error/mod.rsand its message assertion insrc/error/test.rs. -
Implement
RetryPolicy::newusingNonZeroU32, keeping the field private. -
Run
cargo test retryandcargo clippy --all-targets --all-features -- -D warnings.
Files: src/retry/mod.rs, src/retry/test.rs
-
Add failing tests for attempts
0,1, the maximum, and one past it. -
Implement the smallest boundary check:
#[must_use] pub fn allows_attempt(self, attempt: u32) -> bool { attempt != 0 && attempt <= self.max_attempts.get() }
-
Run
cargo test retry.
Files: src/lib.rs, tests/public_api.rs, README.md
- Re-export
RetryPolicyfromsrc/lib.rs. - Add an integration test using only
template::{Error, RetryPolicy}. - Add a runnable README example and rustdoc
# Errorsdocumentation. - Run
cargo test --docandcargo test --test public_api.
-
cargo fmt --all -- --check -
cargo clippy --all-targets --all-features -- -D warnings -
cargo build --all-targets --all-features -
cargo test --all-features -
RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features -
cargo deny check all
When all checks pass, mark the specification Implemented and replace this example status with the actual completion state.