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

Implementations

impl Quoter

fn new() -> Self

Create a new Quoter with default settings.

fn allow_nul(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, 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, in_str: &'a str) -> Result<Cow<'a, str>, QuoteError>

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

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(inner: 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) -> T

Returns the argument unchanged.

impl<T> ToOwned for Quoter where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T, U> Into<U> for Quoter where U: From<T>,

fn into(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<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>