Enum nostr_types::TagV1

source ·
#[repr(u32)]
pub enum TagV1 {
Show 18 variants Address { kind: EventKind, pubkey: PublicKeyHex, d: String, relay_url: Option<UncheckedUrl>, trailing: Vec<String>, }, ContentWarning { warning: String, trailing: Vec<String>, }, Delegation { pubkey: PublicKeyHex, conditions: DelegationConditions, sig: SignatureHex, trailing: Vec<String>, }, Event { id: Id, recommended_relay_url: Option<UncheckedUrl>, marker: Option<String>, trailing: Vec<String>, }, Expiration { time: Unixtime, trailing: Vec<String>, }, Pubkey { pubkey: PublicKeyHex, recommended_relay_url: Option<UncheckedUrl>, petname: Option<String>, trailing: Vec<String>, }, Hashtag { hashtag: String, trailing: Vec<String>, }, Reference { url: UncheckedUrl, marker: Option<String>, trailing: Vec<String>, }, Geohash { geohash: String, trailing: Vec<String>, }, Identifier { d: String, trailing: Vec<String>, }, Subject { subject: String, trailing: Vec<String>, }, Nonce { nonce: String, target: Option<String>, trailing: Vec<String>, }, Parameter { param: String, trailing: Vec<String>, }, Title { title: String, trailing: Vec<String>, }, Other { tag: String, data: Vec<String>, }, Empty = 15, EventParent { id: Id, recommended_relay_url: Option<UncheckedUrl>, trailing: Vec<String>, }, Kind { kind: EventKind, trailing: Vec<String>, },
}
Expand description

A tag on an Event

Variants§

§

Address

Fields

§kind: EventKind

EventKind

§pubkey: PublicKeyHex

Author

§d: String

d-tag identifier

§relay_url: Option<UncheckedUrl>

Relay URL

§trailing: Vec<String>

Trailing

Address ‘a’ tag to a parameterized replaceable event

§

ContentWarning

Fields

§warning: String

Content warning

§trailing: Vec<String>

Trailing

Content Warning to alert client to hide content until user approves

§

Delegation

Fields

§pubkey: PublicKeyHex

Public key of the delegator

§conditions: DelegationConditions

Conditions query string

§sig: SignatureHex

64-byte schnorr signature of the sha256 hash of the delegation token

§trailing: Vec<String>

Trailing

Delegation (Delegated Event Signing)

§

Event

Fields

§id: Id

The Id of some other event that this event refers to

§recommended_relay_url: Option<UncheckedUrl>

A recommended relay URL to find that other event

§marker: Option<String>

A marker (commonly things like ‘reply’)

§trailing: Vec<String>

Trailing

This is a reference to an event, where the first string is the event Id. The second string is defined in NIP-01 as an optional URL, but subsequent ‘e’ NIPs define more data and interpretations.

§

Expiration

Fields

§time: Unixtime

Expiration Time

§trailing: Vec<String>

Trailing

A time when the event should be considered expired

§

Pubkey

Fields

§pubkey: PublicKeyHex

The public key of the identity that this event refers to

§recommended_relay_url: Option<UncheckedUrl>

A recommended relay URL to find information on that public key

§petname: Option<String>

A petname given to this identity by the event author

§trailing: Vec<String>

Trailing

‘p’ This is a reference to a user by public key, where the first string is the PublicKey. The second string is defined in NIP-01 as an optional URL, but subsqeuent NIPs define more data and interpretations.

§

Hashtag

Fields

§hashtag: String

Hashtag

§trailing: Vec<String>

Trailing

‘t’ A hashtag

§

Reference

Fields

§url: UncheckedUrl

A relay url

§marker: Option<String>

An optional marker

§trailing: Vec<String>

Trailing

‘r’ A reference to a URL

§

Geohash

Fields

§geohash: String

A geohash

§trailing: Vec<String>

Trailing

‘g’ A geohash

§

Identifier

Fields

§d: String

‘d’ indentifier

§trailing: Vec<String>

Trailing

‘d’ Identifier tag

§

Subject

Fields

§subject: String

The subject

§trailing: Vec<String>

Trailing

A subject. The first string is the subject. Should only be in TextNote events.

§

Nonce

Fields

§nonce: String

A random number that makes the event hash meet the proof of work required

§target: Option<String>

The target number of bits for the proof of work

§trailing: Vec<String>

Trailing

A nonce tag for Proof of Work

§

Parameter

Fields

§param: String

Parameter

§trailing: Vec<String>

Trailing

There is no known nostr tag like this. This was a mistake, but we can’t remove it or deserialization of data serialized with this in mind will break.

§

Title

Fields

§title: String

Title

§trailing: Vec<String>

Trailing

Title (30023 long form)

§

Other

Fields

§tag: String

The tag name

§data: Vec<String>

The subsequent fields

Any other tag

§

Empty = 15

An empty array (kept so signature remains valid across ser/de)

§

EventParent

Fields

§id: Id

The id of some other event that is the direct parent to this event

§recommended_relay_url: Option<UncheckedUrl>

A recommended relay URL to find that other event

§trailing: Vec<String>

Trailing

Direct parent of an event, ‘E’ tag This is from https://github.com/nostr-protocol/nips/pull/830 which may not happen We should not create these, but we can support them if we encounter them.

§

Kind

Fields

§kind: EventKind

Event kind

§trailing: Vec<String>

Trailing

Kind number ‘k’

Implementations§

source§

impl TagV1

source

pub fn tagname(&self) -> String

Get the tag name for the tag (the first string in the array)a

source

pub fn value(&self, index: usize) -> Result<String, Error>

Get the string value of the tag at an array index

Trait Implementations§

source§

impl Clone for TagV1

source§

fn clone(&self) -> TagV1

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 TagV1

source§

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

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

impl<'de> Deserialize<'de> for TagV1

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 PartialEq for TagV1

source§

fn eq(&self, other: &TagV1) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a_, C_: Context> Readable<'a_, C_> for TagV1

source§

fn read_from<R_: Reader<'a_, C_>>(_reader_: &mut R_) -> Result<Self, C_::Error>

source§

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 Serialize for TagV1

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<C_: Context> Writable<C_> for TagV1

source§

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>

source§

impl Eq for TagV1

source§

impl StructuralPartialEq for TagV1

Auto Trait Implementations§

§

impl RefUnwindSafe for TagV1

§

impl Send for TagV1

§

impl Sync for TagV1

§

impl Unpin for TagV1

§

impl UnwindSafe for TagV1

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> 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> 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> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where 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, U> TryFrom<U> for T
where 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 T
where 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 T
where V: MultiLane<T>,

§

fn vzip(self) -> V

source§

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