Skip to content

feat: implement AsReadFd and AsWriteFd for File - #382

Open
raema wants to merge 2 commits into
monoio-rs:masterfrom
raema:fix-file-asreadfd
Open

feat: implement AsReadFd and AsWriteFd for File#382
raema wants to merge 2 commits into
monoio-rs:masterfrom
raema:fix-file-asreadfd

Conversation

@raema

@raema raema commented Jan 29, 2026

Copy link
Copy Markdown

Problem

monoio::fs::File can't be used with splice traits (SpliceSource, SpliceSink) because it
doesn't implement AsReadFd or AsWriteFd.

Approach

Implement AsReadFd and AsWriteFd for File, matching the pattern used by TcpStream, UnixStream, and Pipe.

The implementation delegates to the file's internal SharedFd:

  • as_reader_fd() -> wraps self.fd in SharedFdWrapper
  • as_writer_fd() -> wraps self.fd in SharedFdWrapper

This enables file.splice_to_pipe() and file.splice_from_pipe() calls.

@raema
raema force-pushed the fix-file-asreadfd branch from 47f4775 to 7f187f8 Compare January 29, 2026 07:44
@raema
raema force-pushed the fix-file-asreadfd branch from 7f187f8 to b26fd0d Compare January 29, 2026 07:52
@ndrscodes

ndrscodes commented Apr 5, 2026

Copy link
Copy Markdown

could we please get this merged? it really is a missing feature right now. @raema do you plan on fixing the failing pipeline?

@Lzzzzzt

Lzzzzzt commented Apr 14, 2026

Copy link
Copy Markdown
Collaborator

@raema hello, there are some CI errors, could you help please fix them? Thanks a lot.

@ndrscodes

Copy link
Copy Markdown

@Lzzzzzt could I open another PR and copy over @raema's changes to this while fixing the issues if @raema does not respond?

@Lzzzzzt

Lzzzzzt commented Apr 14, 2026

Copy link
Copy Markdown
Collaborator

@Lzzzzzt could I open another PR and copy over @raema's changes to this while fixing the issues if @raema does not respond?

sure

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.

3 participants