#[non_exhaustive]pub struct Username(/* private fields */);Expand description
The authenticated user’s username (RFC 8620 §2 username field).
Typically an email address, and therefore PII under GDPR / CCPA. The wrapper exists to centralise PII handling at the type level:
Displayredacts to"[REDACTED]".println!("{}", username),format!("{username}"), andtracing::info!(user = %username, ...)all hitDisplayand therefore the redaction. The pre-bd:JMAP-6r7c.63 shape (pub username: String) leaked the raw value through everyDisplay-bearing path.Debugredacts toUsername("[REDACTED]"). Pre-existingSession::Debugalready redacted explicitly; keeping the wrapper’s own redaction makes the field safe to print even outside theSession::Debugpath (e.g. if a caller stores theUsernamein a struct of their own and derivesDebugon it).Serializeemits the raw value verbatim because the wire format requires it for round-trip. Callers who want to scrub the field before serialising MUST do so explicitly.expose_unredactedis the only path to the raw string. The accessor name is deliberately explicit so the intent is visible at the call site in code review.
Construct via Username::new or via deserialize.
Implementations§
Source§impl Username
impl Username
Sourcepub fn expose_unredacted(&self) -> &str
pub fn expose_unredacted(&self) -> &str
Return the raw, un-redacted username string.
Do not log this return value. This is the only path to the
raw PII; the explicit accessor name surfaces the intent in code
review. Use only when the wire format requires the raw value
(e.g. constructing an Authorization header that re-uses the
username, building an audit log under a separate PII-handling
policy).
Sourcepub fn into_inner(self) -> String
pub fn into_inner(self) -> String
Consume the wrapper and return the inner String.
Same handling guidance as
expose_unredacted — the caller now
owns a raw String and must handle PII manually from that
point on.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Username
impl<'de> Deserialize<'de> for Username
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>,
impl Eq for Username
impl StructuralPartialEq for Username
Auto Trait Implementations§
impl Freeze for Username
impl RefUnwindSafe for Username
impl Send for Username
impl Sync for Username
impl Unpin for Username
impl UnsafeUnpin for Username
impl UnwindSafe for Username
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> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.