Struct yapg::CharsetSpec[][src]

pub struct CharsetSpec { /* fields omitted */ }

Represents a specification for a charset

Any of the predefined CharsetNames can be toggled and additional characters may be included. For this purpose, CharsetSpec implements AddAssign<CharsetName> and SubAssign<CharsetName>. Alternatively, you can parse a string containing the corresponding chars.

Example

let mut spec = yapg::CharsetSpec::empty();
spec += yapg::CharsetName::Numeric; // Adding a named charset
spec += "+-*"; // Adding a string
spec += '/'; // Adding a single char

assert_eq!(spec.construct().as_slice(), [
    '*', '+', '-', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
]);

Implementations

impl CharsetSpec[src]

pub fn construct(self) -> Vec<char>[src]

Builds the actual character set in form of a Vec<char>, which is sorted and deduplicated.

pub fn empty() -> Self[src]

Creates the specification for an empty charset.

Example

let charset = yapg::CharsetSpec::empty().construct();
assert_eq!(charset.len(), 0);

pub fn std64() -> Self[src]

Creates the specification for a standard charset, including all alphanumerics, - and _. Should be safe to use in most places, except for strict “no-special-characters”-policies or where neither - nor _ are considered to be special, yet special chars are required.

Example

let charset = yapg::CharsetSpec::std64().construct();
assert_eq!(charset.len(), 64);

pub fn printable_ascii() -> Self[src]

Creates the specification for charset that contains all printable ASCII characters.

Example

let charset = yapg::CharsetSpec::printable_ascii().construct();
assert_eq!(charset.len(), 95);

Trait Implementations

impl AddAssign<&'_ str> for CharsetSpec[src]

impl AddAssign<CharsetName> for CharsetSpec[src]

impl AddAssign<char> for CharsetSpec[src]

impl Debug for CharsetSpec[src]

impl FromStr for CharsetSpec[src]

type Err = Error

The associated error which can be returned from parsing.

impl Into<Vec<char, Global>> for CharsetSpec[src]

impl SubAssign<CharsetName> for CharsetSpec[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.