Skip to content

Commit eba71ed

Browse files
committed
Improve documents for splice modules
1 parent a8d51a2 commit eba71ed

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

src/uucore/src/lib/features/buf_copy/linux.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ pub fn copy_stream(
2626
if crate::pipes::splice_unbounded_auto(src, dest)? {
2727
// If the splice() call failed, fall back on writing "without buffering", or order of output would be wrong
2828
// unrelated for cp /dev/stdin since cp does not have multiple input? <https://github.com/uutils/coreutils/issues/5186>
29+
// RawWriter also removes io::copy's specialization
2930
std::io::copy(src, &mut crate::io::RawWriter(dest))?;
3031
}
3132
Ok(())

src/uucore/src/lib/features/pipes.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// For the full copyright and license information, please view the LICENSE
44
// file that was distributed with this source code.
55

6-
//! Thin zero-copy-related wrappers around functions.
6+
//! Zero-copy-related functions.
77
88
#[cfg(any(target_os = "linux", target_os = "android"))]
99
use crate::io::{RawReader, RawWriter};
@@ -46,10 +46,8 @@ pub fn pipe<const SIZE_REQUIRED: bool>(s: usize) -> std::io::Result<(PipeReader,
4646
/// Up to `len` bytes are moved from `source` to `target`. Returns the number
4747
/// of successfully moved bytes.
4848
///
49-
/// At least one of `source` and `target` must be some sort of pipe.
50-
/// To get around this requirement, consider splicing from your source into
51-
/// a [`pipe`] and then from the pipe into your target (with `splice_exact`):
52-
/// this is still very efficient.
49+
/// splice fails if both of `source` and `target` are not pipe. Consider using
50+
/// splice_unbounded_broker or splice_unbounded_auto in the case.
5351
#[inline]
5452
#[cfg(any(target_os = "linux", target_os = "android"))]
5553
pub fn splice(source: &impl AsFd, target: &impl AsFd, len: usize) -> rustix::io::Result<usize> {
@@ -102,8 +100,8 @@ pub fn splice_unbounded(source: &impl AsFd, dest: &mut impl AsFd) -> rustix::io:
102100

103101
/// force-splice source to dest even both of them are not pipe via broker pipe
104102
/// returns Ok(Ok(())) if splice succeeds
105-
/// returns Ok(Err()) if splice failed, but you can fallback to read/write
106-
/// returns std::io::Result if splice from broker failed and read/write fallback from broker failed
103+
/// returns Ok(Err(())) if splice failed, but you can fallback to read/write
104+
/// returns Err(e) if splice from broker failed and read/write fallback from broker failed
107105
///
108106
/// Thus, ?.is_err() returns serious error at early stage and checks that you can fallback
109107
/// This should not be used if one of them are pipe to save resources
@@ -163,7 +161,7 @@ pub fn splice_unbounded_auto(source: &impl AsFd, dest: &mut impl AsFd) -> std::i
163161
Ok(fallback)
164162
}
165163

166-
/// splice `n` bytes with safe read/write fallback
164+
/// splice `n` bytes with read/write fallback
167165
/// return actually sent bytes
168166
#[inline]
169167
#[cfg(any(target_os = "linux", target_os = "android"))]

0 commit comments

Comments
 (0)