Skip to main content

RelayMessage

Enum RelayMessage 

Source
#[non_exhaustive]
pub enum RelayMessage<'a> { Event { subscription_id: Cow<'a, SubscriptionId>, event: Cow<'a, Event>, }, Ok { event_id: EventId, accepted: bool, message: Cow<'a, str>, }, Eose(Cow<'a, SubscriptionId>), Closed { subscription_id: Cow<'a, SubscriptionId>, message: Cow<'a, str>, }, Notice(Cow<'a, str>), Auth { challenge: Cow<'a, str>, }, Count { subscription_id: Cow<'a, SubscriptionId>, result: CountResult, }, NegMsg { subscription_id: Cow<'a, SubscriptionId>, message: Cow<'a, str>, }, NegErr { subscription_id: Cow<'a, SubscriptionId>, message: Cow<'a, str>, }, }
Expand description

Relay → client messages.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Event

["EVENT", <id>, <event>] — an event matching a subscription.

Fields

§subscription_id: Cow<'a, SubscriptionId>

Subscription id.

§event: Cow<'a, Event>

The signed event.

§

Ok

["OK", <event id>, <accepted>, <message>].

Fields

§event_id: EventId

The acknowledged event id (64 lowercase hex on the wire).

§accepted: bool

Whether the relay stored the event.

§message: Cow<'a, str>

The machine-readable prefix + human-readable detail.

§

Eose(Cow<'a, SubscriptionId>)

["EOSE", <id>] — end of stored events.

§

Closed

["CLOSED", <id>, <message>] — subscription closed by the relay.

Fields

§subscription_id: Cow<'a, SubscriptionId>

Subscription id.

§message: Cow<'a, str>

The machine-readable prefix + human-readable detail.

§

Notice(Cow<'a, str>)

["NOTICE", <message>] — a free-form notice.

§

Auth

["AUTH", <challenge>] — a NIP-42 auth challenge.

Fields

§challenge: Cow<'a, str>

The challenge string.

§

Count

["COUNT", <id>, <result>] — a NIP-45 count reply.

Fields

§subscription_id: Cow<'a, SubscriptionId>

Subscription id.

§result: CountResult

The count payload.

§

NegMsg

["NEG-MSG", <id>, <hex>] — a NIP-77 sync answer.

Fields

§subscription_id: Cow<'a, SubscriptionId>

Subscription id.

§message: Cow<'a, str>

The negentropy message (non-empty, even-length hex).

§

NegErr

["NEG-ERR", <id>, <message>] — a NIP-77 sync failure.

Fields

§subscription_id: Cow<'a, SubscriptionId>

Subscription id.

§message: Cow<'a, str>

The error detail.

Implementations§

Source§

impl RelayMessage<'_>

Source

pub fn to_json(&self) -> String

The canonical NIP-01 JSON wire form.

Source

pub fn from_json(raw: &str) -> Result<RelayMessage<'static>>

Parses a relay → client JSON message.

§Errors

The same errors as crate::message::ClientMessage::from_json except Error::ObsoleteNegOpen. OK requires a 64-char lowercase hex event id; COUNT ignores non-bool approximate and non-512-hex hll instead of failing.

Source

pub fn into_owned(self) -> RelayMessage<'static>

Converts every borrowed field to owned, giving a 'static message.

Trait Implementations§

Source§

impl<'a> Clone for RelayMessage<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for RelayMessage<'a>

Source§

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

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

impl<'de> Deserialize<'de> for RelayMessage<'static>

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<'a> Eq for RelayMessage<'a>

Source§

impl<'a> PartialEq for RelayMessage<'a>

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Serialize for RelayMessage<'_>

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<'a> StructuralPartialEq for RelayMessage<'a>

Auto Trait Implementations§

§

impl<'a> Forget for RelayMessage<'a>

§

impl<'a> Freeze for RelayMessage<'a>

§

impl<'a> Move for RelayMessage<'a>

§

impl<'a> RefUnwindSafe for RelayMessage<'a>

§

impl<'a> Send for RelayMessage<'a>

§

impl<'a> Sync for RelayMessage<'a>

§

impl<'a> Unpin for RelayMessage<'a>

§

impl<'a> UnsafeUnpin for RelayMessage<'a>

§

impl<'a> UnwindSafe for RelayMessage<'a>

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> 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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.