From 92ef0b56d8e282440676b815ceddb308752b6148 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Thu, 25 Nov 2021 10:43:22 +0100 Subject: [PATCH] move pbs-tools/src/str.rs to pbs-client/src/pxar/create.rs Code is only used there. Signed-off-by: Dietmar Maurer --- pbs-client/src/pxar/create.rs | 12 +++++++++++- pbs-tools/src/lib.rs | 1 - pbs-tools/src/str.rs | 12 ------------ 3 files changed, 11 insertions(+), 14 deletions(-) delete mode 100644 pbs-tools/src/str.rs diff --git a/pbs-client/src/pxar/create.rs b/pbs-client/src/pxar/create.rs index f705e399..92ffeadf 100644 --- a/pbs-client/src/pxar/create.rs +++ b/pbs-client/src/pxar/create.rs @@ -27,7 +27,6 @@ use proxmox_io::vec; use proxmox_lang::c_str; use pbs_datastore::catalog::BackupCatalogWriter; -use pbs_tools::str::strip_ascii_whitespace; use crate::pxar::metadata::errno_is_unsupported; use crate::pxar::Flags; @@ -58,6 +57,17 @@ fn detect_fs_type(fd: RawFd) -> Result { Ok(fs_stat.f_type) } +fn strip_ascii_whitespace(line: &[u8]) -> &[u8] { + let line = match line.iter().position(|&b| !b.is_ascii_whitespace()) { + Some(n) => &line[n..], + None => return &[], + }; + match line.iter().rev().position(|&b| !b.is_ascii_whitespace()) { + Some(n) => &line[..(line.len() - n)], + None => &[], + } +} + #[rustfmt::skip] pub fn is_virtual_file_system(magic: i64) -> bool { use proxmox_sys::linux::magic::*; diff --git a/pbs-tools/src/lib.rs b/pbs-tools/src/lib.rs index 96524ce1..11c8171c 100644 --- a/pbs-tools/src/lib.rs +++ b/pbs-tools/src/lib.rs @@ -7,7 +7,6 @@ pub mod lru_cache; pub mod nom; pub mod percent_encoding; pub mod sha; -pub mod str; pub mod sync; pub mod ticket; diff --git a/pbs-tools/src/str.rs b/pbs-tools/src/str.rs deleted file mode 100644 index 5bea2415..00000000 --- a/pbs-tools/src/str.rs +++ /dev/null @@ -1,12 +0,0 @@ -//! String related utilities. - -pub fn strip_ascii_whitespace(line: &[u8]) -> &[u8] { - let line = match line.iter().position(|&b| !b.is_ascii_whitespace()) { - Some(n) => &line[n..], - None => return &[], - }; - match line.iter().rev().position(|&b| !b.is_ascii_whitespace()) { - Some(n) => &line[..(line.len() - n)], - None => &[], - } -}