pub struct Quoted<'a> { /* private fields */ }Expand description
A wrapper around string types for displaying with quoting and escaping applied.
Implementations§
Source§impl<'a> Quoted<'a>
impl<'a> Quoted<'a>
Sourcepub fn native(text: &'a str) -> Quoted<'a>
pub fn native(text: &'a str) -> Quoted<'a>
Quote a string with the default style for the platform.
On Windows this is PowerShell syntax, on all other platforms this is bash/ksh syntax.
Sourcepub fn native_raw(text: &'a OsStr) -> Quoted<'a>
pub fn native_raw(text: &'a OsStr) -> Quoted<'a>
Quote an OsStr with the default style for the platform.
On platforms other than Windows and Unix, if the encoding is
invalid, the Debug representation will be used.
Sourcepub fn force(self, force: bool) -> Quoted<'a>
pub fn force(self, force: bool) -> Quoted<'a>
Toggle forced quoting. If true, quotes are added even if no special
characters are present.
Defaults to true.
Sourcepub fn external(self, external: bool) -> Quoted<'a>
pub fn external(self, external: bool) -> Quoted<'a>
When quoting for PowerShell, toggle whether to use legacy quoting for external programs.
If enabled, double quotes (and sometimes backslashes) will be escaped so
that they can be passed to external programs in PowerShell versions before
7.3, or with $PSNativeCommandArgumentPassing set to 'Legacy'.
If disabled, quoting will suit modern argument passing (always used for internal commandlets and .NET functions). Strings that look like options or numbers will be quoted.
It is sadly impossible to quote a string such that it’s suitable for both modern and legacy argument passing.
Defaults to false.
§Optional
This requires either the windows or the native feature. It has no effect
on Unix-style quoting.