#[non_exhaustive]pub struct Event {
pub id: EventId,
pub pubkey: PublicKey,
pub created_at: Timestamp,
pub kind: Kind,
pub tags: Tags,
pub content: String,
pub sig: Signature,
}Expand description
Nostr event
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.id: EventIdID
pubkey: PublicKeyAuthor
created_at: TimestampUNIX timestamp (seconds)
kind: KindKind
Tag list
content: StringContent
sig: SignatureSignature
Implementations§
Source§impl Event
impl Event
Sourcepub fn new<I, S>(
id: EventId,
public_key: PublicKey,
created_at: Timestamp,
kind: Kind,
tags: I,
content: S,
sig: Signature,
) -> Event
pub fn new<I, S>( id: EventId, public_key: PublicKey, created_at: Timestamp, kind: Kind, tags: I, content: S, sig: Signature, ) -> Event
Compose event
Sourcepub fn verify_with_ctx<C>(&self, secp: &Secp256k1<C>) -> Result<(), Error>where
C: Verification,
pub fn verify_with_ctx<C>(&self, secp: &Secp256k1<C>) -> Result<(), Error>where
C: Verification,
Sourcepub fn verify_signature(&self) -> bool
pub fn verify_signature(&self) -> bool
Verify only event Signature
Sourcepub fn verify_signature_with_ctx<C>(&self, secp: &Secp256k1<C>) -> boolwhere
C: Verification,
pub fn verify_signature_with_ctx<C>(&self, secp: &Secp256k1<C>) -> boolwhere
C: Verification,
Verify event signature
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Returns true if the event has an expiration tag that is expired.
If an event has no expiration tag, then it will return false.
Sourcepub fn is_expired_with_supplier<T>(&self, supplier: &T) -> boolwhere
T: TimeSupplier,
pub fn is_expired_with_supplier<T>(&self, supplier: &T) -> boolwhere
T: TimeSupplier,
Returns true if the event has an expiration tag that is expired.
If an event has no expiration tag, then it will return false.
Sourcepub fn is_expired_at(&self, now: &Timestamp) -> bool
pub fn is_expired_at(&self, now: &Timestamp) -> bool
Returns true if the event has an expiration tag that is expired.
If an event has no expiration tag, then it will return false.
Sourcepub fn coordinate(&self) -> Option<CoordinateBorrow<'_>>
pub fn coordinate(&self) -> Option<CoordinateBorrow<'_>>
Get the coordinate of this event
Return a coordinate only if the event kind is replaceable or addressable.
Sourcepub fn is_protected(&self) -> bool
pub fn is_protected(&self) -> bool
Check if it’s a protected event
Trait Implementations§
Source§impl AsRef<Event> for VerifiedEvent
impl AsRef<Event> for VerifiedEvent
Source§impl<'de> Deserialize<'de> for Event
impl<'de> Deserialize<'de> for Event
Source§fn deserialize<D>(
deserializer: D,
) -> Result<Event, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Event, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Event
Source§impl JsonUtil for Event
impl JsonUtil for Event
Source§impl Ord for Event
impl Ord for Event
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for Event
impl PartialOrd for Event
Source§impl Serialize for Event
impl Serialize for Event
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
Source§impl ToNostrUri for Event
impl ToNostrUri for Event
Auto Trait Implementations§
impl !Freeze for Event
impl RefUnwindSafe for Event
impl Send for Event
impl Sync for Event
impl Unpin for Event
impl UnsafeUnpin for Event
impl UnwindSafe for Event
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more