Skip to main content

DoubleEscapes

Struct DoubleEscapes 

Source
pub struct DoubleEscapes(/* private fields */);
Expand description

The set of escape sequences that double-quoted values decode.

Each constant enables one sequence. Combine them with union and test them with contains. A backslash pair that is not in the set is handled by Dialect::unknown_escapes. Single-quoted and backtick-quoted values do not use this set.

SetSequences
PORTABLE\n \r \t \\ \" \$
NODE\n \r
PYTHON\n \r \t \\ \" \' \a \b \f \v
COMPOSE\n \r \t \\ \" \$ \a \b \f \v \0

Compose’s octal escape is \0 followed by three octal digits, such as \0101 for A. Otherwise, for example with fewer than three octal digits or a number above 255, only the 0 is removed, so \012 reads \12.

§Examples

use adotenv::{parse_with, Dialect, DoubleEscapes};

let escapes = DoubleEscapes::PORTABLE.union(DoubleEscapes::BELL);
assert!(escapes.contains(DoubleEscapes::LF));

let dialect = Dialect::PORTABLE.with_double_escapes(escapes);
let (doc, _) = parse_with("ALERT=\"ding\\a\"\n", dialect);
assert_eq!(doc.get("ALERT"), Some("ding\u{7}"));

Implementations§

Source§

impl DoubleEscapes

Source

pub const NONE: Self

No escape sequences: every backslash pair is unknown.

Source

pub const LF: Self

\n becomes a line feed (LF).

Source

pub const CR: Self

\r becomes a carriage return (CR).

Source

pub const TAB: Self

\t becomes a tab.

Source

pub const BACKSLASH: Self

\\ becomes one backslash.

Source

pub const DOUBLE_QUOTE: Self

\" becomes a double quote.

Source

pub const DOLLAR: Self

\$ becomes a dollar sign, and the reference after it counts as escaped.

Source

pub const SINGLE_QUOTE: Self

\' becomes a single quote.

Source

pub const BELL: Self

\a becomes the bell character (U+0007).

Source

pub const BACKSPACE: Self

\b becomes a backspace (U+0008).

Source

pub const FORM_FEED: Self

\f becomes a form feed (U+000C).

Source

pub const VERTICAL_TAB: Self

\v becomes a vertical tab (U+000B).

Source

pub const OCTAL: Self

Compose’s octal escape: \0 followed by three octal digits.

Source

pub const PORTABLE: Self

Portable’s set: \n, \r, \t, \\, \" and \$.

Source

pub const NODE: Self

Node dotenv’s set: \n and \r.

Source

pub const PYTHON: Self

python-dotenv’s set: Portable’s without \$, plus \', \a, \b, \f and \v.

Source

pub const COMPOSE: Self

Compose’s set: Portable’s plus \a, \b, \f, \v and the octal \0 escape.

Source

pub const fn union(self, other: Self) -> Self

Returns the set of sequences enabled in either self or other.

Source

pub const fn contains(self, other: Self) -> bool

Checks whether every sequence in other is also enabled in self.

Trait Implementations§

Source§

impl Clone for DoubleEscapes

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for DoubleEscapes

Source§

impl Debug for DoubleEscapes

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for DoubleEscapes

Source§

impl Hash for DoubleEscapes

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for DoubleEscapes

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for DoubleEscapes

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.