Struct Quoter

struct Quoter { ... }

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 bytes equivalent is bytes::Quoter.

Implementations

impl Quoter

fn new() -> Self

Create a new Quoter with default settings.

fn allow_nul(self: Self, allow: bool) -> Self

Set 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 str>>(self: &Self, words: I) -> Result<String, QuoteError>

Convenience function that consumes an iterable of words and turns it into a single string, quoting words when necessary. Consecutive words will be separated by a single space.

fn quote<'a>(self: &Self, in_str: &'a str) -> Result<Cow<'a, str>, QuoteError>

Given a single word, return a string suitable to encode it as a shell argument.

impl Clone for Quoter

fn clone(self: &Self) -> Quoter

impl Debug for Quoter

fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result

impl Default for Quoter

fn default() -> Quoter

impl Freeze for Quoter

impl From for Quoter

fn from(inner: Quoter) -> 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

impl<T> Any for Quoter

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for Quoter

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for Quoter

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> CloneToUninit for Quoter

unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)

impl<T> From for Quoter

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for Quoter

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T, U> Into for Quoter

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for Quoter

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for Quoter

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>