Struct UniversalString
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::string::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§
§impl UniversalString
impl UniversalString
pub 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::string::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());
pub 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§
§impl Clone for UniversalString
impl Clone for UniversalString
§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 more§impl Debug for UniversalString
impl Debug for UniversalString
§impl Hash for UniversalString
impl Hash for UniversalString
§impl PartialEq for UniversalString
impl PartialEq for UniversalString
§impl TryFrom<&str> for UniversalString
impl TryFrom<&str> for UniversalString
§fn try_from(
value: &str,
) -> Result<UniversalString, <UniversalString as TryFrom<&str>>::Error>
fn try_from( value: &str, ) -> Result<UniversalString, <UniversalString as TryFrom<&str>>::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.
§impl TryFrom<String> for UniversalString
impl TryFrom<String> for UniversalString
§fn try_from(
value: String,
) -> Result<UniversalString, <UniversalString as TryFrom<String>>::Error>
fn try_from( value: String, ) -> Result<UniversalString, <UniversalString as TryFrom<String>>::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.
impl Eq for UniversalString
impl StructuralPartialEq for UniversalString
Auto Trait Implementations§
impl Freeze for UniversalString
impl RefUnwindSafe for UniversalString
impl Send for UniversalString
impl Sync for UniversalString
impl Unpin for UniversalString
impl UnwindSafe for UniversalString
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy
that returns Action::Follow
only if self
and other
return
Action::Follow
. Read more