[][src]Trait bcder::string::CharSet

pub trait CharSet {
    pub const TAG: Tag;

    pub fn next_char<I: Iterator<Item = u8>>(
        iter: &mut I
    ) -> Result<Option<char>, CharSetError>;
pub fn from_str(s: &str) -> Result<Cow<'_, [u8]>, CharSetError>; pub fn check<I: Iterator<Item = u8>>(
        iter: &mut I
    ) -> Result<(), CharSetError> { ... } }

The character set of a restricted character string type.

The trait only includes associated functions and can thus be implemented for marker types. It main purpose is to take an iterator over u8s and produce chars or errors. This happens in next_char.

The trait is primarily used to define the character set of the RestrictedString type.

Associated Constants

pub const TAG: Tag[src]

The natural tag of the related restricted character string type.

Loading content...

Required methods

pub fn next_char<I: Iterator<Item = u8>>(
    iter: &mut I
) -> Result<Option<char>, CharSetError>
[src]

Returns the next character from a octet sequence.

pub fn from_str(s: &str) -> Result<Cow<'_, [u8]>, CharSetError>[src]

Converts a str into a octet sequence.

The method takes a str and converts it into one of three things. If the string can be encoded in this character set and its own octet sequence is identical to the encoded sequence, it returns its octet sequence as a Ok(Cow::Borrowed(_)). If the octet sequence differs, it creates that and returns it as a Ok(Cow::Owned(_)). Finally, if the string cannot be encoded in this character set, it returns an error.

Loading content...

Provided methods

pub fn check<I: Iterator<Item = u8>>(iter: &mut I) -> Result<(), CharSetError>[src]

Checks whether a sequence of octets is a valid string.

The method returns an error if the sequence of the octets represented by iter is not in fact a valid string for this character set.

Loading content...

Implementors

Loading content...