pub struct NameBook { /* private fields */ }Expand description
A DID → name map, populated by the caller from data it already holds.
Insertion is idempotent and order-independent: a lower-ranked source never displaces a higher-ranked one, so a command can fill the book from several responses in whatever order they arrive without the result depending on that order.
Implementations§
Source§impl NameBook
impl NameBook
pub fn new() -> NameBook
Sourcepub fn insert(&mut self, did: impl Into<String>, name: DisplayName)
pub fn insert(&mut self, did: impl Into<String>, name: DisplayName)
Record a name for did, keeping whichever source ranks higher.
Empty and whitespace-only names are dropped rather than stored: an
unset label deserialises as Some("") often enough that storing it
would put a blank string where the DID should be.
Sourcepub fn insert_opt(
&mut self,
did: impl Into<String>,
name: Option<&str>,
source: NameSource,
)
pub fn insert_opt( &mut self, did: impl Into<String>, name: Option<&str>, source: NameSource, )
Convenience for the common case: an Option<String> label straight
off a response struct.
pub fn get(&self, did: &str) -> Option<&DisplayName>
pub fn is_empty(&self) -> bool
pub fn len(&self) -> usize
Sourcepub fn names_any<'a>(&self, dids: impl IntoIterator<Item = &'a str>) -> bool
pub fn names_any<'a>(&self, dids: impl IntoIterator<Item = &'a str>) -> bool
Whether any DID in dids has a name.
Table renderers call this to decide whether to emit a NAME column at all — on a VTA where nothing has been labelled, a column of dashes is worse than no column.
Sourcepub fn name_of(&self, did: &str) -> Option<String>
pub fn name_of(&self, did: &str) -> Option<String>
The name for did as a bare string, tagged when unverified.
Returns None when the DID has no name, so callers can decide between
a placeholder and the shortened DID.
Sourcepub fn render_inline(&self, did: &str) -> String
pub fn render_inline(&self, did: &str) -> String
One-line rendering for prose and confirmations:
mediator-prod (did:webvh:QmXk…9f2:example.com).
Falls back to the shortened DID alone when there is no name. The DID is always present — a name the operator cannot cross-check against an identifier is a name they cannot audit.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for NameBook
impl RefUnwindSafe for NameBook
impl Send for NameBook
impl Sync for NameBook
impl Unpin for NameBook
impl UnsafeUnpin for NameBook
impl UnwindSafe for NameBook
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> BorrowUnordered for T
impl<T> BorrowUnordered for T
fn as_unordered(&self) -> &Unordered<T>
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Clear for Twhere
T: InitializableFromZeroed + ?Sized,
impl<T> Clear for Twhere
T: InitializableFromZeroed + ?Sized,
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> InitializableFromZeroed for Twhere
T: Default,
impl<T> InitializableFromZeroed for Twhere
T: Default,
Source§unsafe fn initialize(place: *mut T)
unsafe fn initialize(place: *mut T)
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> 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 moreSource§impl<T, U, C> IntoWithContext<U, C> for Twhere
U: FromWithContext<T, C>,
impl<T, U, C> IntoWithContext<U, C> for Twhere
U: FromWithContext<T, C>,
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> ResourceProvider<()> for T
impl<T> ResourceProvider<()> for T
Source§fn get_resource(&self) -> &()
fn get_resource(&self) -> &()
T.