[−][src]Trait bcder::string::CharSet
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 u8
s and
produce char
s or errors. This happens in next_char
.
The trait is primarily used to define the character set of the
RestrictedString
type.
Associated Constants
Loading content...Required methods
fn next_char<I: Iterator<Item = u8>>(
iter: &mut I
) -> Result<Option<char>, CharSetError>
iter: &mut I
) -> Result<Option<char>, CharSetError>
Returns the next character from a octet sequence.
fn from_str(s: &str) -> Result<Cow<[u8]>, CharSetError>
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.
Provided methods
fn check<I: Iterator<Item = u8>>(iter: &mut I) -> Result<(), CharSetError>
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.