Struct Quoter
pub struct Quoter { /* private fields */ }
A more configurable interface to quote strings. If you only want the default settings you can
use the convenience functions try_quote and try_join.
The string equivalent is shlex::Quoter.
Implementations
impl Quoter
fn new() -> SelfCreate a new
Quoterwith default settings.fn allow_nul(self, allow: bool) -> SelfSet whether to allow nul bytes. By default they are not allowed and will result in an error of
QuoteError::Nul.fn join<'a, I: IntoIterator<Item = &'a [u8]>>(&self, words: I) -> Result<Vec<u8>, QuoteError>Convenience function that consumes an iterable of words and turns it into a single byte string, quoting words when necessary. Consecutive words will be separated by a single space.
fn quote<'a>(&self, in_bytes: &'a [u8]) -> Result<Cow<'a, [u8]>, QuoteError>Given a single word, return a byte string suitable to encode it as a shell argument.
If given valid UTF-8, this will never produce invalid UTF-8. This is because it only ever inserts valid ASCII characters before or after existing ASCII characters (or returns two single quotes if the input was an empty string). It will never modify a multibyte UTF-8 character.
Trait Implementations
impl Clone for Quoter
fn clone(&self) -> Quoter
impl Debug for Quoter
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Default for Quoter
fn default() -> Quoter
impl From<Quoter> for Quoter
fn from(quoter: Quoter) -> Quoter
Auto Trait Implementations
impl Freeze for Quoter
impl RefUnwindSafe for Quoter
impl Send for Quoter
impl Sync for Quoter
impl Unpin for Quoter
impl UnsafeUnpin for Quoter
impl UnwindSafe for Quoter
Blanket Implementations
impl<T> Any for Quoter
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for Quoter
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for Quoter
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for Quoter
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for Quoter
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for Quoter
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T, U> Into<U> for Quoter
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for Quoter
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for Quoter
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>