ITADN

Splice with offset support

#383OpenYangchenYe323 创建于 2026-02-26
F-feature-request
Y
YangchenYe323commented
**Is your feature request related to a problem? Please describe.** It'd be nice to expose the ability to set offset on splicing. My use case is to splice a file to a network socket in a storage system. ``` // Currently our Splice does not support setting offset. pub(crate) struct Splice { fd_in: SharedFd, fd_out: SharedFd, len: u32, direction: SpliceDirection, } ``` **Describe the solution you'd like** I have a private patch with basically modified the `SpliceDestination` and `SpliceSource` trait to have another method: ``` /// Splice data from self to pipe. pub trait SpliceSource { /// Splice data from self to pipe. fn splice_to_pipe<'a>( &'a mut self, pipe: &'a mut Pipe, len: u32, ) -> impl Future<Output = std::io::Result<u32>>; fn splice_to_pipe_at<'a>( &'a mut self, pipe: &'a mut Pipe, len: u32, offset: i64, ) -> impl Future<Output = std::io::Result<u32>>; } /// Splice data from self from pipe. pub trait SpliceDestination { /// Splice data from self from pipe. fn splice_from_pipe<'a>( &'a mut self, pipe: &'a mut Pipe, len: u32, ) -> impl Future<Output = std::io::Result<u32>>; fn splice_from_pipe_to<'a>( &'a mut self, pipe: &'a mut Pipe, len: u32, offset: i64, ) -> impl Future<Output = std::io::Result<u32>>; } ``` Is there any technical reason that this is a bad idea that I wasn't aware of? Happy to open a PR if this is considered acceptable **Describe alternatives you've considered** A clear and concise description of any alternative solutions or features you've considered. **Additional context** Add any other context or screenshots about the feature request here.
0 条评论