Struct nostr_types::EventV1
source · pub struct EventV1 {
pub id: Id,
pub pubkey: PublicKey,
pub created_at: Unixtime,
pub kind: EventKind,
pub sig: Signature,
pub ots: Option<String>,
pub content: String,
pub tags: Vec<TagV1>,
}
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.
ots: Option<String>
DEPRECATED (please set to Null): An optional verified time for the event (using OpenTimestamp)
content: String
The content of the event
A set of tags that apply to the event
Implementations§
source§impl EventV1
impl EventV1
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<(PublicKeyHex, Option<RelayUrl>, Option<String>)>
pub fn people(&self) -> Vec<(PublicKeyHex, 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 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<(Id, String, Option<RelayUrl>)>
pub fn reacts_to(&self) -> Option<(Id, String, Option<RelayUrl>)>
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<Id>, String)>
pub fn deletes(&self) -> Option<(Vec<Id>, String)>
If this event deletes others, get all the Ids of the events that it deletes along with the reason for the deletion
sourcepub fn zaps(&self) -> Result<Option<ZapDataV1>, Error>
pub fn zaps(&self) -> Result<Option<ZapDataV1>, Error>
If this event zaps another event, get data about that.
That includes the Id, the amount, and the public key of the provider, all of which should be verified by the caller.
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 content_warning(&self) -> Option<String>
pub fn content_warning(&self) -> Option<String>
If this event specifies a content warning, return that subject string
Return all the hashtags this event refers to
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 EventV1
impl EventV1
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_ots_from_speedy_bytes(bytes: &[u8]) -> Option<&str>
pub fn get_ots_from_speedy_bytes(bytes: &[u8]) -> Option<&str>
Read the ots 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 Tag 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.