pub struct UniversalString(/* private fields */);
Expand description
ASN.1 UniversalString
type.
§Examples
You can create a UniversalString
from a literal string with UniversalString::try_from
:
use rcgen::UniversalString;
let hello = UniversalString::try_from("hello").unwrap();
§Supported characters
The characters which can appear in the UniversalString
type are any of the characters allowed by
ISO/IEC 10646 (Unicode).
Bytes are encoded like UTF-32 big-endian.
UniversalString
is included for backward compatibility, RFC 5280 say it
SHOULD NOT be used for certificates for new subjects.
Implementations§
Source§impl UniversalString
impl UniversalString
Sourcepub fn as_bytes(&self) -> &[u8] ⓘ
pub fn as_bytes(&self) -> &[u8] ⓘ
Returns a byte slice of this UniversalString
’s contents.
The inverse of this method is from_utf32be
.
§Examples
use rcgen::UniversalString;
let s = UniversalString::try_from("hello").unwrap();
assert_eq!(&[0, 0, 0, 104, 0, 0, 0, 101, 0, 0, 0, 108, 0, 0, 0, 108, 0, 0, 0, 111], s.as_bytes());
Sourcepub fn from_utf32be(vec: Vec<u8>) -> Result<UniversalString, Error>
pub fn from_utf32be(vec: Vec<u8>) -> Result<UniversalString, Error>
Decode a UTF-32BE–encoded vector vec
into a UniversalString
, returning Err if vec
contains any invalid data.
Trait Implementations§
Source§impl Clone for UniversalString
impl Clone for UniversalString
Source§fn clone(&self) -> UniversalString
fn clone(&self) -> UniversalString
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for UniversalString
impl Debug for UniversalString
Source§impl Hash for UniversalString
impl Hash for UniversalString
Source§impl PartialEq for UniversalString
impl PartialEq for UniversalString
Source§impl TryFrom<&str> for UniversalString
impl TryFrom<&str> for UniversalString
Source§fn try_from(value: &str) -> Result<Self, Self::Error>
fn try_from(value: &str) -> Result<Self, Self::Error>
Converts a &str
to a UniversalString
.
Any character not in the UniversalString
charset will be rejected.
See UniversalString
documentation for more information.
The result is allocated on the heap.
Source§impl TryFrom<String> for UniversalString
impl TryFrom<String> for UniversalString
Source§fn try_from(value: String) -> Result<Self, Self::Error>
fn try_from(value: String) -> Result<Self, Self::Error>
Converts a String
into a UniversalString
Any character not in the UniversalString
charset will be rejected.
See UniversalString
documentation for more information.
Parsing a UniversalString
allocates memory since the UTF-8 to UTF-32 conversion requires a memory allocation.