Skip to content

cold: type-erased backend via DynColdStorageBackend#63

Open
prestwich wants to merge 8 commits into
mainfrom
prestwich/cold-dyn-backend
Open

cold: type-erased backend via DynColdStorageBackend#63
prestwich wants to merge 8 commits into
mainfrom
prestwich/cold-dyn-backend

Conversation

@prestwich
Copy link
Copy Markdown
Member

[Claude Code]

Summary

  • Introduces DynColdStorageBackend, an object-safe mirror of ColdStorageBackend with Pin<Box<dyn Future>> returns, auto-implemented for every B: ColdStorageBackend via a blanket impl. Arc<dyn DynColdStorageBackend> is wired to satisfy ColdStorageBackend, and ColdStorage<B> defaults B to that erased form plus a new_erased constructor — so downstream code can write plain ColdStorage without a turbofish when it wants runtime backend swappability, or ColdStorage<MyBackend> for full monomorphization.
  • get_logs / produce_log_stream on the erased path eagerly clone the Filter because the unified-lifetime dyn signature cannot bridge the independent-lifetime strong-trait signature without an owned filter. All other methods dispatch with zero overhead. Concrete ColdStorage<B> is unaffected. See the module docs in dyn_backend.rs.
  • Adds a conformance_erased entry point so the existing conformance suite runs against Arc<dyn DynColdStorageBackend>, and a focused unit test that verifies a backend's drain_above override survives erasure. Writing those tests caught and fixed an infinite-recursion hazard in the clone-form methods (the cloned Arc<dyn ...> resolved the blanket impl back into the strong-trait impl — fix: qualified-path dispatch via Arc::as_ref()). The recursion hazard is documented in a maintainer note for any future borrowed-arg method.

Test plan

  • cargo +nightly fmt -- --check
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo clippy --workspace --all-targets --no-default-features -- -D warnings
  • `RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps`
  • cargo t -p signet-cold --all-features — including new erased_conformance and dyn_drain_above_invokes_backend_override tests

🤖 Generated with Claude Code

prestwich and others added 8 commits May 13, 2026 11:31
Cosmetic: one blank-line-separated group per module + its re-export.
No semantic change.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Also fix infinite recursion in the Arc<dyn DynColdStorageBackend>
ColdStorageRead impl: get_logs and produce_log_stream were cycling
back through the blanket DynColdStorageBackend impl. Fixed by calling
DynColdStorageBackend::dyn_* directly on the inner trait object via
Arc::as_ref(), bypassing the blanket dispatch loop.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Workspace doc build runs with -D warnings which enables
rustdoc::redundant_explicit_links. The label already auto-resolves
to crate::Filter via the prelude, so the explicit target is rejected.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant