Skip to content

Comments

feat: implement AsReadFd and AsWriteFd for File#382

Open
raema wants to merge 1 commit intobytedance:masterfrom
raema:fix-file-asreadfd
Open

feat: implement AsReadFd and AsWriteFd for File#382
raema wants to merge 1 commit intobytedance:masterfrom
raema:fix-file-asreadfd

Conversation

@raema
Copy link

@raema raema commented Jan 29, 2026

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
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