apache / apache/arrow-rs

Wrap all `tokio::io::AsyncWrite` types to a specific type which is implemented `AsyncFileWriter`

Open
#6,327 9 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Rust
Stars
3.6k
Forks
1.3k
Avg merge
2d 18h
Merged PRs (30d)
169

Description

In current, parquet defines all `AsyncWrite` implement `AsyncFileWriter`:
```rust
impl AsyncFileWriter for T {
... ...
}
```

which would in conflict with:
```rust
impl AsyncFileWriter for &mut T {
... ...
}
```

this definition is not included right now, however, it should be helpful in more general cases, numerous of similar cases choose to implement this, such as:
- [tokio::io::AsyncWrite](https://docs.rs/tokio/latest/tokio/io/trait.AsyncWrite.html#impl-AsyncWrite-for-%26mut+T)
- [futures::io::AsyncWrite](https://docs.rs/futures/latest/futures/io/trait.AsyncWrite.html#impl-AsyncWrite-for-%26mut+T)

**Describe the solution you'd like**
Wrap all tokio::io::AsyncWrite into a proxy struct, then we can define `&mut AsyncFileWriter` implements `AsyncFileWriter`:
```rust
pub struct TokioFileWriter {
file: F,
}

impl From for TokioFileWriter {
... ...
}

impl for TokioFileWriter {
... ...
}

```

**Describe alternatives you've considered**
I don't think there is an alternatives.

**Additional context**
This is a breaking change, but it values to be considered.

Contributor guide

Open the contributing guide

Research direction

Start with the AsyncFileWriter blanket implementation and the proposed TokioFileWriter proxy described in the issue. Examine how tokio::io::AsyncWrite types are currently adapted, then determine the compatibility and breaking-change implications of enabling an AsyncFileWriter implementation for &mut T. Done means the proxy and forwarding behavior are defined without conflicting implementations.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
data-engineering
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.