mirror of
https://github.com/uutils/coreutils.git
synced 2026-05-06 07:26:38 -04:00
refactor(buf_copy): remove unused code
This commit is contained in:
committed by
Daniel Hofstetter
parent
5316f58726
commit
8754b0dcf9
@@ -9,8 +9,6 @@
|
||||
//! used by utilities to work around the limitations of Rust's `fs::copy` which
|
||||
//! does not handle copying special files (e.g pipes, character/block devices).
|
||||
|
||||
pub mod common;
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
pub mod linux;
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
// This file is part of the uutils coreutils package.
|
||||
//
|
||||
// For the full copyright and license information, please view the LICENSE
|
||||
// file that was distributed with this source code.
|
||||
|
||||
use crate::error::UError;
|
||||
|
||||
/// Error types used by buffer-copying functions from the `buf_copy` module.
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
Io(std::io::Error),
|
||||
WriteError(String),
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Error {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::WriteError(msg) => write!(f, "splice() write error: {msg}"),
|
||||
Self::Io(err) => write!(f, "I/O error: {err}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::error::Error for Error {}
|
||||
|
||||
impl UError for Error {
|
||||
fn code(&self) -> i32 {
|
||||
1
|
||||
}
|
||||
|
||||
fn usage(&self) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
@@ -13,8 +13,6 @@ use std::{
|
||||
os::fd::{AsFd, AsRawFd},
|
||||
};
|
||||
|
||||
use super::common::Error;
|
||||
|
||||
/// A readable file descriptor.
|
||||
pub trait FdReadable: Read + AsRawFd + AsFd {}
|
||||
|
||||
@@ -25,13 +23,6 @@ pub trait FdWritable: Write + AsFd + AsRawFd {}
|
||||
|
||||
impl<T> FdWritable for T where T: Write + AsFd + AsRawFd {}
|
||||
|
||||
/// Conversion from a `rustix::io::Errno` into our `Error` which implements `UError`.
|
||||
impl From<rustix::io::Errno> for Error {
|
||||
fn from(error: rustix::io::Errno) -> Self {
|
||||
Self::Io(std::io::Error::from(error))
|
||||
}
|
||||
}
|
||||
|
||||
/// Copy data from `Read` implementor `source` into a `Write` implementor
|
||||
/// `dest`. This works by reading a chunk of data from `source` and writing the
|
||||
/// data to `dest` in a loop.
|
||||
|
||||
Reference in New Issue
Block a user