pub struct UserStatus {
pub status_type: StatusType,
pub content: String,
pub link: Option<StatusLink>,
pub expires_at: Option<Timestamp>,
}Expand description
A parsed or freshly constructed user status.
Fields§
§status_type: StatusTypeStatus type (maps to the addressable d tag).
content: StringStatus text. An empty string is a spec-level clear signal.
link: Option<StatusLink>Optional link (at most one; see StatusLink).
expires_at: Option<Timestamp>Optional NIP-40 expiration.
Implementations§
Source§impl UserStatus
impl UserStatus
Sourcepub fn new(status_type: StatusType, content: impl Into<String>) -> Self
pub fn new(status_type: StatusType, content: impl Into<String>) -> Self
Construct a new status with only the two required pieces.
Sourcepub fn with_link(self, link: StatusLink) -> Self
pub fn with_link(self, link: StatusLink) -> Self
Attach a link. At most one link is carried; subsequent calls replace the previous value (matches the builder’s behaviour).
Sourcepub const fn with_expiration(self, ts: Timestamp) -> Self
pub const fn with_expiration(self, ts: Timestamp) -> Self
Attach an NIP-40 expiration.
Sourcepub const fn is_clear(&self) -> bool
pub const fn is_clear(&self) -> bool
true when Self::content is empty — the spec’s clear
signal.
Sourcepub fn from_event(event: &Event) -> Result<Self, UserStatusError>
pub fn from_event(event: &Event) -> Result<Self, UserStatusError>
Parse a NIP-38 event back into the typed bundle.
§Errors
UserStatusError::WrongKindfor any kind other thanKIND_USER_STATUS.UserStatusError::MissingDTagwhen the addressabled-identifier is absent.
Trait Implementations§
Source§impl Clone for UserStatus
impl Clone for UserStatus
Source§fn clone(&self) -> UserStatus
fn clone(&self) -> UserStatus
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for UserStatus
impl Debug for UserStatus
impl Eq for UserStatus
Source§impl PartialEq for UserStatus
impl PartialEq for UserStatus
impl StructuralPartialEq for UserStatus
Auto Trait Implementations§
impl Freeze for UserStatus
impl RefUnwindSafe for UserStatus
impl Send for UserStatus
impl Sync for UserStatus
impl Unpin for UserStatus
impl UnsafeUnpin for UserStatus
impl UnwindSafe for UserStatus
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
Mutably borrows from an owned value. Read more
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,
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
Compare self to
key and return true if they are equal.