pub struct Metadata {
pub name: Option<String>,
pub display_name: Option<String>,
pub about: Option<String>,
pub website: Option<Url>,
pub picture: Option<Url>,
pub banner: Option<Url>,
pub nip05: Option<String>,
pub lud06: Option<String>,
pub lud16: Option<String>,
pub bot: Option<bool>,
pub birthday: Option<Birthday>,
pub custom: Map<String, Value>,
}Expand description
User profile metadata published as the content of a kind: 0 event.
Every field is optional; unknown JSON properties survive a round-trip via
Metadata::custom.
Fields§
§name: Option<String>Short username, e.g. alice.
display_name: Option<String>Display name (NIP-24).
about: Option<String>Biographical description.
website: Option<Url>Personal web site (NIP-24).
picture: Option<Url>Profile picture URL.
Banner image URL (NIP-24).
nip05: Option<String>NIP-05 verification identifier (alice@example.com).
lud06: Option<String>LNURL-pay identifier (legacy LUD-06).
lud16: Option<String>Lightning Address (LUD-16).
bot: Option<bool>NIP-24 bot flag: true if the profile is fully or partially
automated (chatbots, newsfeeds, AI agents).
birthday: Option<Birthday>NIP-24 birthday object. Every component (year / month /
day) is individually optional so partial dates (e.g.
month-and-day only) round-trip cleanly.
custom: Map<String, Value>Forward-compatible escape hatch: any property the spec adds (or any project-specific custom property) is preserved verbatim here.
Two NIP-24 deprecated fields intentionally land here rather than in dedicated fields:
displayName(camel-case) — superseded bySelf::display_name;username— superseded bySelf::name.
Access them via Self::legacy_display_name and
Self::legacy_username when a caller needs to migrate an old
profile without dropping bytes.
Implementations§
Source§impl Metadata
impl Metadata
Sourcepub fn with_display_name<S: Into<String>>(self, name: S) -> Self
pub fn with_display_name<S: Into<String>>(self, name: S) -> Self
Set the display_name field (NIP-24).
Sourcepub fn with_about<S: Into<String>>(self, about: S) -> Self
pub fn with_about<S: Into<String>>(self, about: S) -> Self
Set the about field.
Sourcepub fn with_website(self, website: Url) -> Self
pub fn with_website(self, website: Url) -> Self
Set the website field.
Sourcepub fn with_picture(self, picture: Url) -> Self
pub fn with_picture(self, picture: Url) -> Self
Set the picture field.
Set the banner field (NIP-24).
Sourcepub fn with_nip05<S: Into<String>>(self, nip05: S) -> Self
pub fn with_nip05<S: Into<String>>(self, nip05: S) -> Self
Set the nip05 field.
Sourcepub fn with_lud06<S: Into<String>>(self, lud06: S) -> Self
pub fn with_lud06<S: Into<String>>(self, lud06: S) -> Self
Set the lud06 field (legacy LNURL-pay).
Sourcepub fn with_lud16<S: Into<String>>(self, lud16: S) -> Self
pub fn with_lud16<S: Into<String>>(self, lud16: S) -> Self
Set the lud16 field (Lightning Address).
Sourcepub const fn with_birthday(self, birthday: Birthday) -> Self
pub const fn with_birthday(self, birthday: Birthday) -> Self
Set the NIP-24 birthday object.
Sourcepub fn legacy_display_name(&self) -> Option<&str>
pub fn legacy_display_name(&self) -> Option<&str>
Return the deprecated NIP-24 displayName value if the profile
was produced by an older client. Prefer Self::display_name
for every new write path.
Sourcepub fn legacy_username(&self) -> Option<&str>
pub fn legacy_username(&self) -> Option<&str>
Return the deprecated NIP-24 username value. Prefer
Self::name for every new write path.
Sourcepub fn with_custom<S, V>(self, key: S, value: V) -> Self
pub fn with_custom<S, V>(self, key: S, value: V) -> Self
Insert a custom JSON property.
Useful for extensions defined by future NIPs that this crate has not modelled yet.
Sourcepub fn to_event_content(&self) -> Result<String, Error>
pub fn to_event_content(&self) -> Result<String, Error>
Render self as the JSON string that goes into a kind: 0 event’s
content field.
§Errors
Returns the underlying serde_json error if the metadata cannot be
serialized (in practice impossible for user metadata, but serde_json
keeps the type fallible).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Metadata
impl<'de> Deserialize<'de> for Metadata
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 Metadata
impl StructuralPartialEq for Metadata
Auto Trait Implementations§
impl Freeze for Metadata
impl RefUnwindSafe for Metadata
impl Send for Metadata
impl Sync for Metadata
impl Unpin for Metadata
impl UnsafeUnpin for Metadata
impl UnwindSafe for Metadata
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.