pub struct ApplicationData {
pub identifier: String,
pub content: String,
pub extra_tags: Vec<Tag>,
}Expand description
Typed bundle for a NIP-78 kind: 30078 event.
The d tag (= Self::identifier) is the only required wire
element; everything else is opaque payload that the producing
app interprets however it likes.
Fields§
§identifier: Stringd-tag value. Spec recommends a reverse-DNS or vendor-prefixed
identifier such as com.example.todoapp so unrelated apps do
not collide on the same (pubkey, 30078, d) coordinate.
content: StringFree-form .content. Often JSON, but any string works.
Any additional tags the app stamped on the event. They are
preserved on a Self::from_event round-trip so consumers
never silently lose data.
Implementations§
Source§impl ApplicationData
impl ApplicationData
Sourcepub fn new(identifier: impl Into<String>) -> Self
pub fn new(identifier: impl Into<String>) -> Self
Construct an empty bundle bound to identifier.
Sourcepub fn tag(self, tag: Tag) -> Self
pub fn tag(self, tag: Tag) -> Self
Append an app-defined tag.
d-tags submitted here are silently dropped — the addressable
identifier is owned by Self::identifier and the builder
pins exactly one d tag at the head of the event.
Append several app-defined tags.
Sourcepub fn from_event(event: &Event) -> Result<Self, ApplicationDataError>
pub fn from_event(event: &Event) -> Result<Self, ApplicationDataError>
Parse a kind: 30078 event back into a typed bundle.
§Errors
ApplicationDataError::WrongKindfor any other kind.ApplicationDataError::MissingIdentifierwhen nodtag is present (the event would not be addressable without one).
Trait Implementations§
Source§impl Clone for ApplicationData
impl Clone for ApplicationData
Source§fn clone(&self) -> ApplicationData
fn clone(&self) -> ApplicationData
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ApplicationData
impl Debug for ApplicationData
Source§impl Default for ApplicationData
impl Default for ApplicationData
Source§fn default() -> ApplicationData
fn default() -> ApplicationData
impl Eq for ApplicationData
Source§impl PartialEq for ApplicationData
impl PartialEq for ApplicationData
impl StructuralPartialEq for ApplicationData
Auto Trait Implementations§
impl Freeze for ApplicationData
impl RefUnwindSafe for ApplicationData
impl Send for ApplicationData
impl Sync for ApplicationData
impl Unpin for ApplicationData
impl UnsafeUnpin for ApplicationData
impl UnwindSafe for ApplicationData
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,
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.