#[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
Event
["EVENT", <id>, <event>] — an event matching a subscription.
Fields
subscription_id: Cow<'a, SubscriptionId>Subscription id.
Ok
["OK", <event id>, <accepted>, <message>].
Fields
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.
Notice(Cow<'a, str>)
["NOTICE", <message>] — a free-form notice.
Auth
["AUTH", <challenge>] — a NIP-42 auth challenge.
Count
["COUNT", <id>, <result>] — a NIP-45 count reply.
Fields
subscription_id: Cow<'a, SubscriptionId>Subscription id.
result: CountResultThe count payload.
NegMsg
["NEG-MSG", <id>, <hex>] — a NIP-77 sync answer.
Fields
subscription_id: Cow<'a, SubscriptionId>Subscription id.
NegErr
["NEG-ERR", <id>, <message>] — a NIP-77 sync failure.
Implementations§
Source§impl RelayMessage<'_>
impl RelayMessage<'_>
Sourcepub fn from_json(raw: &str) -> Result<RelayMessage<'static>>
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.
Sourcepub fn into_owned(self) -> RelayMessage<'static>
pub fn into_owned(self) -> RelayMessage<'static>
Converts every borrowed field to owned, giving a 'static message.