#[non_exhaustive]pub enum ClientMessage<'a> {
Event(Cow<'a, Event>),
Req {
subscription_id: Cow<'a, SubscriptionId>,
filters: Cow<'a, [Filter]>,
},
Count {
subscription_id: Cow<'a, SubscriptionId>,
filters: Cow<'a, [Filter]>,
},
Close(Cow<'a, SubscriptionId>),
Auth(Cow<'a, Event>),
NegOpen {
subscription_id: Cow<'a, SubscriptionId>,
filter: Cow<'a, Filter>,
message: Cow<'a, str>,
},
NegMsg {
subscription_id: Cow<'a, SubscriptionId>,
message: Cow<'a, str>,
},
NegClose(Cow<'a, SubscriptionId>),
}Expand description
Client → relay messages (NIP-01 + NIP-42 AUTH + NIP-45 COUNT + NIP-77).
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Event(Cow<'a, Event>)
["EVENT", <event>] — publish a signed event.
Req
["REQ", <id>, <filter>, ...] — open a subscription.
Fields
subscription_id: Cow<'a, SubscriptionId>Subscription id.
Count
["COUNT", <id>, <filter>, ...] — a NIP-45 count request.
Fields
subscription_id: Cow<'a, SubscriptionId>Subscription id.
filters: Cow<'a, [Filter]>Same rules as ClientMessage::Req::filters.
Close(Cow<'a, SubscriptionId>)
["CLOSE", <id>] — close a subscription.
Auth(Cow<'a, Event>)
["AUTH", <event>] — a NIP-42 kind-22242 auth event.
NegOpen
["NEG-OPEN", <id>, <filter>, <hex>] — open a NIP-77 sync.
Fields
subscription_id: Cow<'a, SubscriptionId>Subscription id.
NegMsg
["NEG-MSG", <id>, <hex>] — continue a NIP-77 sync.
Fields
subscription_id: Cow<'a, SubscriptionId>Subscription id.
NegClose(Cow<'a, SubscriptionId>)
["NEG-CLOSE", <id>] — end a NIP-77 sync.
Implementations§
Source§impl ClientMessage<'_>
impl ClientMessage<'_>
Sourcepub fn from_json(raw: &str) -> Result<ClientMessage<'static>>
pub fn from_json(raw: &str) -> Result<ClientMessage<'static>>
Parses a client → relay JSON message.
§Errors
Error::InvalidJson when the text is not JSON,
Error::NotAMessageArray when it is not a non-empty array starting
with the type string, Error::UnknownType for an unrecognized
type, Error::InvalidMessage for wrong arity or field types,
Error::InvalidPayload when an embedded event or filter fails
wire validation, Error::InvalidSubscriptionId for a bad
subscription id, Error::ObsoleteNegOpen for the 5-element
NEG-OPEN, and Error::InvalidNegMessage for malformed NEG hex.
Sourcepub fn into_owned(self) -> ClientMessage<'static>
pub fn into_owned(self) -> ClientMessage<'static>
Converts every borrowed field to owned, giving a 'static message.