Struct OpenPgpUserId
pub struct OpenPgpUserId(OpenPgpUserIdType);Expand description
A basic representation of a User ID for OpenPGP
While OpenPGP User IDs are loosely defined to be UTF-8 strings, they do not enforce particular rules around the use of e-mail addresses or their general length. This type allows to distinguish between plain UTF-8 strings and valid e-mail addresses. Valid e-mail addresses must provide a display part, use a top-level domain (TLD) and not rely on domain literals (e.g. IP address). The length of a User ID is implicitly limited by the maximum length of an OpenPGP packet (8192 bytes). As such, this type only allows a maximum length of 4096 bytes as middle ground.
Tuple Fields§
§0: OpenPgpUserIdTypeImplementations§
§impl OpenPgpUserId
impl OpenPgpUserId
pub fn new(user_id: String) -> Result<OpenPgpUserId, Error>
pub fn new(user_id: String) -> Result<OpenPgpUserId, Error>
Creates a new OpenPgpUserId from a String
§Errors
Returns an [Error::UserIdTooLarge] if the chars of the provided String exceed
4096 bytes. This ensures to stay below the valid upper limit defined by the maximum OpenPGP
packet size of 8192 bytes.
§Examples
use std::str::FromStr;
use signstar_crypto::openpgp::OpenPgpUserId;
assert!(!OpenPgpUserId::new("🤡".to_string())?.is_email());
assert!(OpenPgpUserId::new("🤡 <foo@xn--rl8h.org>".to_string())?.is_email());
// an e-mail without a display name is not considered a valid e-mail
assert!(!OpenPgpUserId::new("<foo@xn--rl8h.org>".to_string())?.is_email());
// this fails because the provided String is too long
assert!(OpenPgpUserId::new("U".repeat(4097)).is_err());pub fn is_email(&self) -> bool
pub fn is_email(&self) -> bool
Returns whether the OpenPgpUserId is a valid e-mail address
§Examples
use signstar_crypto::openpgp::OpenPgpUserId;
assert!(!OpenPgpUserId::new("🤡".to_string())?.is_email());
assert!(OpenPgpUserId::new("🤡 <foo@xn--rl8h.org>".to_string())?.is_email());Trait Implementations§
§impl AsRef<str> for OpenPgpUserId
impl AsRef<str> for OpenPgpUserId
§impl Clone for OpenPgpUserId
impl Clone for OpenPgpUserId
§fn clone(&self) -> OpenPgpUserId
fn clone(&self) -> OpenPgpUserId
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for OpenPgpUserId
impl Debug for OpenPgpUserId
§impl<'de> Deserialize<'de> for OpenPgpUserId
impl<'de> Deserialize<'de> for OpenPgpUserId
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<OpenPgpUserId, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<OpenPgpUserId, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl Display for OpenPgpUserId
impl Display for OpenPgpUserId
§impl FromStr for OpenPgpUserId
impl FromStr for OpenPgpUserId
§impl Hash for OpenPgpUserId
impl Hash for OpenPgpUserId
§impl PartialEq for OpenPgpUserId
impl PartialEq for OpenPgpUserId
§impl Serialize for OpenPgpUserId
impl Serialize for OpenPgpUserId
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
§impl TryFrom<&SignedUser> for OpenPgpUserId
impl TryFrom<&SignedUser> for OpenPgpUserId
§fn try_from(
value: &SignedUser,
) -> Result<OpenPgpUserId, <OpenPgpUserId as TryFrom<&SignedUser>>::Error>
fn try_from( value: &SignedUser, ) -> Result<OpenPgpUserId, <OpenPgpUserId as TryFrom<&SignedUser>>::Error>
Creates an OpenPgpUserId from [SignedUser].
§Errors
Returns an error if the [SignedUser]’s User ID can not be converted to a valid UTF-8
string.
§impl TryFrom<String> for OpenPgpUserId
impl TryFrom<String> for OpenPgpUserId
impl Eq for OpenPgpUserId
impl StructuralPartialEq for OpenPgpUserId
Auto Trait Implementations§
impl Freeze for OpenPgpUserId
impl RefUnwindSafe for OpenPgpUserId
impl Send for OpenPgpUserId
impl Sync for OpenPgpUserId
impl Unpin for OpenPgpUserId
impl UnwindSafe for OpenPgpUserId
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,
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.