#[non_exhaustive]pub enum Message {
Request {
id: String,
method: Method,
params: Vec<String>,
},
Response {
id: String,
result: Option<String>,
error: Option<String>,
},
}Available on crate feature
nip46 only.Expand description
Wire envelope: a request or a response.
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.
Request
Request frame.
Fields
Response
Response frame.
Implementations§
Source§impl Message
impl Message
Sourcepub fn request(id: impl Into<String>, request: &Request) -> Self
pub fn request(id: impl Into<String>, request: &Request) -> Self
Build a request envelope from a typed Request and an
arbitrary id (typically a random u32 or a UUID).
Sourcepub fn response(id: impl Into<String>, response: Response) -> Self
pub fn response(id: impl Into<String>, response: Response) -> Self
Build a response envelope from a typed Response and the
originating request id.
Sourcepub fn into_request(self) -> Result<Request, Nip46Error>
pub fn into_request(self) -> Result<Request, Nip46Error>
Decode a Self::Request envelope into a typed Request.
§Errors
Returns Nip46Error::WrongMessageKind when the envelope is
actually a response, and forwards every parse error from
Request::from_wire.
Sourcepub fn into_response(self, method: Method) -> Result<Response, Nip46Error>
pub fn into_response(self, method: Method) -> Result<Response, Nip46Error>
Decode a Self::Response envelope into a typed Response.
§Errors
Returns Nip46Error::WrongMessageKind when the envelope is
actually a request, and forwards every parse error from
Response::from_wire.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Message
impl<'de> Deserialize<'de> for Message
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Message
impl StructuralPartialEq for Message
Auto Trait Implementations§
impl Freeze for Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnsafeUnpin for Message
impl UnwindSafe for Message
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.