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.
Trait Implementations§
source§impl<'de> Deserialize<'de> for EventV1
impl<'de> Deserialize<'de> for EventV1
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<'a_, C_: Context> Readable<'a_, C_> for EventV1
impl<'a_, C_: Context> Readable<'a_, C_> for EventV1
fn read_from<R_: Reader<'a_, C_>>(_reader_: &mut R_) -> Result<Self, C_::Error>
fn minimum_bytes_needed() -> usize
fn read_from_buffer_with_ctx( context: C, buffer: &'a [u8], ) -> Result<Self, <C as Context>::Error>
fn read_with_length_from_buffer_with_ctx( context: C, buffer: &'a [u8], ) -> (Result<Self, <C as Context>::Error>, usize)
fn read_from_buffer_copying_data_with_ctx( context: C, buffer: &[u8], ) -> Result<Self, <C as Context>::Error>
fn read_with_length_from_buffer_copying_data_with_ctx( context: C, buffer: &[u8], ) -> (Result<Self, <C as Context>::Error>, usize)
fn read_with_length_from_buffer_copying_data_with_ctx_mut( context: &mut C, buffer: &[u8], ) -> (Result<Self, <C as Context>::Error>, usize)
fn read_from_stream_unbuffered_with_ctx<S>(
context: C,
stream: S,
) -> Result<Self, <C as Context>::Error>where
S: Read,
fn read_from_stream_buffered_with_ctx<S>(
context: C,
stream: S,
) -> Result<Self, <C as Context>::Error>where
S: Read,
fn read_from_file_with_ctx( context: C, path: impl AsRef<Path>, ) -> Result<Self, <C as Context>::Error>
source§impl<C_: Context> Writable<C_> for EventV1
impl<C_: Context> Writable<C_> for EventV1
fn write_to<T_: ?Sized + Writer<C_>>( &self, _writer_: &mut T_, ) -> Result<(), C_::Error>
fn write_to_buffer_with_ctx( &self, context: C, buffer: &mut [u8], ) -> Result<(), <C as Context>::Error>
fn write_to_buffer_with_ctx_mut( &self, context: &mut C, buffer: &mut [u8], ) -> Result<(), <C as Context>::Error>
fn write_to_vec_with_ctx( &self, context: C, ) -> Result<Vec<u8>, <C as Context>::Error>
fn write_to_vec_with_ctx_mut( &self, context: &mut C, ) -> Result<Vec<u8>, <C as Context>::Error>
fn write_to_stream_with_ctx<S>(
&self,
context: C,
stream: S,
) -> Result<(), <C as Context>::Error>where
S: Write,
fn write_to_file_with_ctx( &self, context: C, path: impl AsRef<Path>, ) -> Result<(), <C as Context>::Error>
fn bytes_needed(&self) -> Result<usize, <C as Context>::Error>
impl Eq for EventV1
impl StructuralPartialEq for EventV1
Auto Trait Implementations§
impl Freeze for EventV1
impl RefUnwindSafe for EventV1
impl Send for EventV1
impl Sync for EventV1
impl Unpin for EventV1
impl UnwindSafe for EventV1
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)