pub struct SignatureRef<'a> {
pub name: &'a BStr,
pub email: &'a BStr,
pub time: &'a str,
}Expand description
An immutable signature that is created by an actor at a certain time.
All of its fields are references to the backing buffer to allow lossless
round-tripping, as decoding the time field could be a lossy transformation.
Note that this is not a cryptographical signature.
Fields§
§name: &'a BStrThe actors name, potentially with whitespace as parsed.
Use SignatureRef::trim() or trim manually for cleanup.
email: &'a BStrThe actor’s email, potentially with whitespace and garbage as parsed.
Use SignatureRef::trim() or trim manually for cleanup.
time: &'a strThe timestamp at which the signature was performed, potentially malformed due to lenient parsing.
Use SignatureRef::time() to decode.
Implementations§
Source§impl<'a> SignatureRef<'a>
Lifecycle
impl<'a> SignatureRef<'a>
Lifecycle
Sourcepub fn from_bytes<E>(data: &'a [u8]) -> Result<SignatureRef<'a>, ErrMode<E>>
pub fn from_bytes<E>(data: &'a [u8]) -> Result<SignatureRef<'a>, ErrMode<E>>
Deserialize a signature from the given data.
Source§impl<'a> SignatureRef<'a>
Access
impl<'a> SignatureRef<'a>
Access
Sourcepub fn trim(&self) -> SignatureRef<'a>
pub fn trim(&self) -> SignatureRef<'a>
Trim the whitespace surrounding the name, email and time and return a new signature.
Sourcepub fn actor(&self) -> IdentityRef<'a>
pub fn actor(&self) -> IdentityRef<'a>
Return the actor’s name and email, effectively excluding the timestamp of this signature.
Sourcepub fn seconds(&self) -> SecondsSinceUnixEpoch
pub fn seconds(&self) -> SecondsSinceUnixEpoch
Parse only the seconds since unix epoch from the time field, or silently default to 0
if parsing fails. Note that this ignores the timezone, so it can parse otherwise broken dates.
For a fallible and more complete, but slower version, use time().
Trait Implementations§
Source§impl<'a> Clone for SignatureRef<'a>
impl<'a> Clone for SignatureRef<'a>
Source§fn clone(&self) -> SignatureRef<'a>
fn clone(&self) -> SignatureRef<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'a> Debug for SignatureRef<'a>
impl<'a> Debug for SignatureRef<'a>
Source§impl<'a> Default for SignatureRef<'a>
impl<'a> Default for SignatureRef<'a>
Source§fn default() -> SignatureRef<'a>
fn default() -> SignatureRef<'a>
Source§impl<'de: 'a, 'a> Deserialize<'de> for SignatureRef<'a>
impl<'de: 'a, 'a> Deserialize<'de> for SignatureRef<'a>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl From<SignatureRef<'_>> for Signature
Note that this conversion is lossy due to the lenient parsing of the time field.
impl From<SignatureRef<'_>> for Signature
Note that this conversion is lossy due to the lenient parsing of the time field.