Xuanwo opened a new issue, #8854:
URL: https://github.com/apache/opendal/issues/8854

   > AI-authored issue from a read-only readability audit against `main` 
(`615a8f24f`), guided by the optimize-for-reading guidelines in #8847.
   
   ### Problem
   
   Several internal state machines split their payload fields outside their 
`State` enum or encode closed state implicitly via `Option::None`, forcing 
readers to track cross-field invariants via comments, `.take()` / `.expect()`, 
or `debug_assert!`:
   
   1. **`Copier`** (`core/core/src/types/copy.rs:41-71`):
      - Maintains `copier: Option<oio::Copier>`, `fut: 
Option<BoxedStaticFuture<Step>>`, and `state: State` as three separate fields, 
relying on comments and `.take()`/`.expect()` to keep them in sync across 
`Idle` / `InFlight` / `Failed` / `Closed` / `Aborted`.
      - Moving `oio::Copier` and `BoxedStaticFuture<Step>` directly into the 
corresponding `State` variants makes the invariants compiler-checked and 
readable in one enum definition.
   2. **`BufferSink`** (`core/core/src/types/write/buffer_sink.rs:37-71`):
      - Encodes the closed state implicitly as `State::Idle(None)` 
(`is_closed()` checks `matches!(self.state, State::Idle(None))`). Adding an 
explicit `State::Closed` variant removes the `Option` nesting.
   3. **`FuturesDeleteSink`** 
(`core/core/src/types/delete/futures_delete_sink.rs:35-75`):
      - Same implicit `State::Idle(None)` encoding for closed/errored state; an 
explicit `State::Closed` variant makes transitions clearer.
   4. **`CompleteWriter<W>`** (`core/core/src/layers/complete.rs:391-420`):
      - Maintains `inner: Option<W>` separately from `state: CompleteState` and 
relies on `debug_assert_ne!` checks.
      - Its generic parameter `W` is only ever instantiated as `oio::Writer` 
across the workspace and can also be removed.
   
   ### Coordination Notes
   
   - Open PR #8846 currently modifies 
`core/core/src/types/write/buffer_sink.rs`. Sequence the `BufferSink` portion 
after #8846 merges (or handle independently in separate PRs).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to