Struct Event

Source
pub struct Event {
    pub words: Vec<Vec<u8>>,
    /* private fields */
}
Expand description

The default event document.

Fields§

§words: Vec<Vec<u8>>

Implementations§

Source§

impl Event

Source

pub fn new( id: [u8; 32], pubkey: [u8; 32], created_at: u64, kind: u16, tags: Vec<Vec<String>>, content: String, sig: [u8; 64], ) -> Result<Self, Error>

Source

pub fn create( key_pair: &Keypair, created_at: u64, kind: u16, tags: Vec<Vec<String>>, content: String, ) -> Result<Self, Error>

Source§

impl Event

Source

pub fn to_json(&self) -> Result<String, Error>

to json string

Source

pub fn index(&self) -> &EventIndex

Source

pub fn id(&self) -> &[u8; 32]

Source

pub fn id_str(&self) -> String

Source

pub fn pubkey(&self) -> &[u8; 32]

Source

pub fn pubkey_str(&self) -> String

Source

pub fn created_at(&self) -> u64

Source

pub fn kind(&self) -> u16

Source

pub fn tags(&self) -> &Vec<Vec<String>>

Source

pub fn content(&self) -> &String

Source

pub fn sig(&self) -> &[u8; 64]

Source§

impl Event

Source

pub fn hash(&self) -> [u8; 32]

Source

pub fn verify_id(&self) -> Result<(), Error>

Source

pub fn verify_sign(&self) -> Result<(), Error>

Source

pub fn verify_time(&self, now: u64, older: u64, newer: u64) -> Result<(), Error>

check event created time newer than (now - older), older than (now + newer) ignore when 0

Source

pub fn verify_delegation(&self) -> Result<(), Error>

Source

pub fn validate(&self, now: u64, older: u64, newer: u64) -> Result<(), Error>

Trait Implementations§

Source§

impl AsRef<Event> for Event

Source§

fn as_ref(&self) -> &Event

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for Event

Source§

fn clone(&self) -> Event

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Event

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Event

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Event

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl FromEventData for Event

Parse the json string to event object

Source§

fn from_data<S: AsRef<[u8]>>(json: S) -> Result<Self, Self::Err>

decode the json data to event object

Source§

type Err = Error

Source§

fn only_id() -> bool

only pass the event id to from_data
Source§

impl FromStr for Event

Source§

type Err = Error

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Serialize for Event

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TryInto<String> for Event

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<String, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl Freeze for Event

§

impl RefUnwindSafe for Event

§

impl Send for Event

§

impl Sync for Event

§

impl Unpin for Event

§

impl UnwindSafe for Event

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

Source§

fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Gets the layout of the type.
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The type for metadata in pointers and references to Self.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,