pub struct GeneralString(pub Vec<u8>);Expand description
ASN.1 GeneralString (tag 27)
An 8-bit character set. In practice (Kerberos, X.500) this is used as Latin-1 or ASCII. No character set validation is performed; bytes are exposed raw.
Tuple Fields§
§0: Vec<u8>Implementations§
Source§impl GeneralString
impl GeneralString
Sourcepub fn from_ascii(s: &str) -> Result<Self>
pub fn from_ascii(s: &str) -> Result<Self>
Create a new GeneralString from an ASCII string slice.
Returns an error if any character is outside the ASCII range (U+0000..=U+007F).
The bytes are copied with a single memcpy; no per-character processing is needed
because ASCII code points equal their UTF-8 byte representations.
Sourcepub fn from_ascii_string(s: String) -> Result<Self>
pub fn from_ascii_string(s: String) -> Result<Self>
Create a new GeneralString from an owned ASCII String.
Returns an error if any character is outside the ASCII range (U+0000..=U+007F).
On success the String’s heap buffer is reused directly via String::into_bytes;
no extra allocation is performed.
Sourcepub fn from_str_lossy(s: &str) -> Self
pub fn from_str_lossy(s: &str) -> Self
Create a new GeneralString from a string, encoding it as Latin-1 (lossy).
Characters above U+00FF are silently truncated to their low 8 bits.
Prefer GeneralString::from_ascii which returns an error for out-of-range
characters.
Sourcepub fn as_latin1_string(&self) -> String
pub fn as_latin1_string(&self) -> String
Decode the bytes as a Latin-1 string.
Trait Implementations§
Source§impl Clone for GeneralString
impl Clone for GeneralString
Source§fn clone(&self) -> GeneralString
fn clone(&self) -> GeneralString
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for GeneralString
impl Debug for GeneralString
Source§impl Decode<'_> for GeneralString
impl Decode<'_> for GeneralString
Source§impl Encode for GeneralString
impl Encode for GeneralString
Source§impl PartialEq for GeneralString
impl PartialEq for GeneralString
Source§fn eq(&self, other: &GeneralString) -> bool
fn eq(&self, other: &GeneralString) -> bool
self and other values to be equal, and is used by ==.Source§impl Tagged for GeneralString
impl Tagged for GeneralString
impl Eq for GeneralString
impl StructuralPartialEq for GeneralString
Auto Trait Implementations§
impl Freeze for GeneralString
impl RefUnwindSafe for GeneralString
impl Send for GeneralString
impl Sync for GeneralString
impl Unpin for GeneralString
impl UnsafeUnpin for GeneralString
impl UnwindSafe for GeneralString
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> TagForOptional for Twhere
T: Tagged,
impl<T> TagForOptional for Twhere
T: Tagged,
Source§fn optional_tag() -> Option<Tag>
fn optional_tag() -> Option<Tag>
None if
the type accepts multiple tags (CHOICE) or any tag (ANY / Element<'a>).