Struct nostr_types::EventV3
source · pub struct EventV3 {
pub id: Id,
pub pubkey: PublicKey,
pub created_at: Unixtime,
pub kind: EventKind,
pub sig: Signature,
pub content: String,
pub tags: Vec<TagV3>,
}
Expand description
The main event type
Fields§
§id: Id
The Id of the event, generated as a SHA256 of the inner event data
pubkey: PublicKey
The public key of the actor who created the event
created_at: Unixtime
The (unverified) time at which the event was created
kind: EventKind
The kind of event
sig: Signature
The signature of the event, which cryptographically verifies that the holder of the PrivateKey matching the event’s PublicKey generated (or authorized) this event. The signature is taken over the id field only, but the id field is taken over the rest of the event data.
content: String
The content of the event
A set of tags that apply to the event
Implementations§
source§impl EventV3
impl EventV3
sourcepub fn verify(&self, maxtime: Option<Unixtime>) -> Result<(), Error>
pub fn verify(&self, maxtime: Option<Unixtime>) -> Result<(), Error>
Check the validity of an event. This is useful if you deserialize an event from the network. If you create an event using new() it should already be trustworthy.
sourcepub fn k_tag_kind(&self) -> Option<EventKind>
pub fn k_tag_kind(&self) -> Option<EventKind>
Get the k-tag kind, if any
sourcepub fn people(&self) -> Vec<(PublicKey, Option<RelayUrl>, Option<String>)>
pub fn people(&self) -> Vec<(PublicKey, Option<RelayUrl>, Option<String>)>
If the event refers to people by tag, get all the PublicKeys it refers to along with recommended relay URL and petname for each
sourcepub fn people_referenced_in_content(&self) -> Vec<PublicKey>
pub fn people_referenced_in_content(&self) -> Vec<PublicKey>
If the event refers to people within the contents, get all the PublicKeys it refers to within the contents.
sourcepub fn referred_events(&self) -> Vec<EventReference>
pub fn referred_events(&self) -> Vec<EventReference>
All events IDs that this event refers to, whether root, reply, mention, or otherwise along with optional recommended relay URLs
sourcepub fn replies_to(&self) -> Option<EventReference>
pub fn replies_to(&self) -> Option<EventReference>
Get a reference to another event that this event replies to. An event can only reply to one other event via ‘e’ or ‘a’ tag from a feed-displayable event that is not a Repost.
sourcepub fn replies_to_root(&self) -> Option<EventReference>
pub fn replies_to_root(&self) -> Option<EventReference>
If this event replies to a thread, get that threads root event Id if available, along with an optional recommended_relay_url
sourcepub fn quotes(&self) -> Vec<EventReference>
pub fn quotes(&self) -> Vec<EventReference>
If this event quotes others, get those other events
sourcepub fn mentions(&self) -> Vec<EventReference>
pub fn mentions(&self) -> Vec<EventReference>
If this event mentions others, get those other event Ids and optional recommended relay Urls
sourcepub fn reacts_to(&self) -> Option<(EventReference, String)>
pub fn reacts_to(&self) -> Option<(EventReference, String)>
If this event reacts to another, get that other event’s Id, the reaction content, and an optional Recommended relay Url
sourcepub fn deletes(&self) -> Option<(Vec<EventReference>, String)>
pub fn deletes(&self) -> Option<(Vec<EventReference>, String)>
If this event deletes others, get all the EventReferences of the events that it deletes along with the reason for the deletion
Can this event be deleted by the given public key?
sourcepub fn zaps(&self) -> Result<Option<ZapData>, Error>
pub fn zaps(&self) -> Result<Option<ZapData>, Error>
If this event zaps another event, get data about that.
Errors returned from this are not fatal, but may be useful for explaining to a user why a zap receipt is invalid.
sourcepub fn client(&self) -> Option<String>
pub fn client(&self) -> Option<String>
If this event specifies the client that created it, return that client string
sourcepub fn subject(&self) -> Option<String>
pub fn subject(&self) -> Option<String>
If this event specifies a subject, return that subject string
sourcepub fn title(&self) -> Option<String>
pub fn title(&self) -> Option<String>
If this event specifies a title, return that title string
sourcepub fn summary(&self) -> Option<String>
pub fn summary(&self) -> Option<String>
If this event specifies a summary, return that summary string
sourcepub fn is_annotation(&self) -> bool
pub fn is_annotation(&self) -> bool
Is this event an annotation
sourcepub fn content_warning(&self) -> Option<Option<String>>
pub fn content_warning(&self) -> Option<Option<String>>
If this event specifies a content warning, return that content warning
Return all the hashtags this event refers to
sourcepub fn file_metadata(&self) -> Vec<FileMetadata>
pub fn file_metadata(&self) -> Vec<FileMetadata>
Return all attached FileMetadata objects
sourcepub fn delegation(&self) -> EventDelegation
pub fn delegation(&self) -> EventDelegation
Was this event delegated, was that valid, and if so what is the pubkey of the delegator?
source§impl EventV3
impl EventV3
sourcepub fn get_id_from_speedy_bytes(bytes: &[u8]) -> Option<Id>
pub fn get_id_from_speedy_bytes(bytes: &[u8]) -> Option<Id>
Read the ID of the event from a speedy encoding without decoding (zero allocation)
Note this function is fragile, if the Event structure is reordered, or if speedy code changes, this will break. Neither should happen.
sourcepub fn get_pubkey_from_speedy_bytes(bytes: &[u8]) -> Option<PublicKey>
pub fn get_pubkey_from_speedy_bytes(bytes: &[u8]) -> Option<PublicKey>
Read the pubkey of the event from a speedy encoding without decoding (close to zero allocation, VerifyingKey does stuff I didn’t check)
Note this function is fragile, if the Event structure is reordered, or if speedy code changes, this will break. Neither should happen.
sourcepub fn get_created_at_from_speedy_bytes(bytes: &[u8]) -> Option<Unixtime>
pub fn get_created_at_from_speedy_bytes(bytes: &[u8]) -> Option<Unixtime>
Read the created_at of the event from a speedy encoding without decoding (zero allocation)
Note this function is fragile, if the Event structure is reordered, or if speedy code changes, this will break. Neither should happen.
sourcepub fn get_kind_from_speedy_bytes(bytes: &[u8]) -> Option<EventKind>
pub fn get_kind_from_speedy_bytes(bytes: &[u8]) -> Option<EventKind>
Read the kind of the event from a speedy encoding without decoding (zero allocation)
Note this function is fragile, if the Event structure is reordered, or if speedy code changes, this will break. Neither should happen.
sourcepub fn get_content_from_speedy_bytes(bytes: &[u8]) -> Option<&str>
pub fn get_content_from_speedy_bytes(bytes: &[u8]) -> Option<&str>
Read the content of the event from a speedy encoding without decoding (zero allocation)
Note this function is fragile, if the Event structure is reordered, or if speedy code changes, this will break. Neither should happen.
sourcepub fn tag_search_in_speedy_bytes(
bytes: &[u8],
re: &Regex,
) -> Result<bool, Error>
pub fn tag_search_in_speedy_bytes( bytes: &[u8], re: &Regex, ) -> Result<bool, Error>
Check if any human-readable tag matches the Regex in the speedy encoding without decoding the whole thing (because our TagV3 representation is so complicated, we do deserialize the tags for now)
Note this function is fragile, if the Event structure is reordered, or if speedy code changes, this will break. Neither should happen.
Trait Implementations§
source§impl<'de> Deserialize<'de> for EventV3
impl<'de> Deserialize<'de> for EventV3
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>,
source§impl Ord for EventV3
impl Ord for EventV3
source§impl PartialEq for EventV3
impl PartialEq for EventV3
source§impl PartialOrd for EventV3
impl PartialOrd for EventV3
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more