Struct yapg::CharsetSpec [−][src]
Represents a specification for a charset
Any of the predefined CharsetName
s 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]
fn add_assign(&mut self, more: &str)
[src]
impl AddAssign<CharsetName> for CharsetSpec
[src]
fn add_assign(&mut self, name: CharsetName)
[src]
impl AddAssign<char> for CharsetSpec
[src]
fn add_assign(&mut self, c: char)
[src]
impl Debug for CharsetSpec
[src]
impl FromStr for CharsetSpec
[src]
type Err = Error
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Self>
[src]
impl Into<Vec<char, Global>> for CharsetSpec
[src]
impl SubAssign<CharsetName> for CharsetSpec
[src]
fn sub_assign(&mut self, name: CharsetName)
[src]
Auto Trait Implementations
impl RefUnwindSafe for CharsetSpec
impl Send for CharsetSpec
impl Sync for CharsetSpec
impl Unpin for CharsetSpec
impl UnwindSafe for CharsetSpec
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,