Struct nostr_db::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: Vec<u8>, pubkey: Vec<u8>, created_at: u64, kind: u64, tags: Vec<Vec<String>>, content: String, sig: Vec<u8> ) -> Result<Self, Error>

source

pub fn create( key_pair: &KeyPair, created_at: u64, kind: u64, 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) -> &Vec<u8>

source

pub fn id_str(&self) -> String

source

pub fn pubkey(&self) -> &Vec<u8>

source

pub fn pubkey_str(&self) -> String

source

pub fn created_at(&self) -> u64

source

pub fn kind(&self) -> u64

source

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

source

pub fn content(&self) -> &String

source

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

source§

impl Event

source

pub fn hash(&self) -> Vec<u8>

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 copy 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 Default for Event

source§

fn default() -> Event

Returns the “default value” for a type. 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

§

type Err = Error

source§

fn only_id() -> bool

only pass the event id to from_data
source§

impl FromStr for Event

§

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

§

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 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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> ArchivePointee for T

§

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 Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere 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 Twhere 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.
§

impl<T> Pointee for T

§

type Metadata = ()

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

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

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

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

§

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 Twhere U: TryFrom<T>,

§

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.
§

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

§

fn vzip(self) -> V

source§

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