mirror of
https://github.com/allankoechke/rust.git
synced 2026-11-30 11:05:36 +00:00
Add a strategy FnMut to inject behavior into the flush cycle This PR adds the interface needed to avoid forking FileEncoder in https://github.com/rust-lang/rust/pull/154724. This adds a FnMut used as a strategy/observer to see the bytes being flushed to disk. For https://github.com/rust-lang/rust/pull/154724, that would be used to calculate the metadata hash on the raw metadata bytes. The 'static hack is pretty ugly, but otherwise, the FileEncoder lifetime goes exceptionally viral and requires some very unfortunate workarounds to avoid self referential lifetimes. That's a bit of a timebomb if the wrong FileEncoder client tries to use the new API, but the worst case outcome is a wild goose chase of lifetime chasing. Full disclosure: I used Claude Code to generate much of the PR. I have fully reviewed the code and stand behind it. r? @cjgillot