Enum jsonrpc_lite::JsonRpc
source · [−]pub enum JsonRpc {
Request(Request),
Notification(Notification),
Success(Success),
Error(Error),
}
Expand description
JSON-RPC 2.0 Request object and Response object JSON-RPC 2.0 Specification.
Variants
Request(Request)
Request object
Notification(Notification)
Notification object
Success(Success)
Success Response
Error(Error)
Error Response
Implementations
sourceimpl JsonRpc
impl JsonRpc
sourcepub fn request<I: Into<Id>>(id: I, method: &str) -> Self
pub fn request<I: Into<Id>>(id: I, method: &str) -> Self
Creates a JSON-RPC 2.0 request object without params
sourcepub fn request_with_params<I: Into<Id>, P: Into<Params>>(
id: I,
method: &str,
params: P
) -> Self
pub fn request_with_params<I: Into<Id>, P: Into<Params>>(
id: I,
method: &str,
params: P
) -> Self
Creates a JSON-RPC 2.0 request object with params
sourcepub fn notification(method: &str) -> Self
pub fn notification(method: &str) -> Self
Creates a JSON-RPC 2.0 notification object without params
sourcepub fn notification_with_params<P: Into<Params>>(method: &str, params: P) -> Self
pub fn notification_with_params<P: Into<Params>>(method: &str, params: P) -> Self
Creates a JSON-RPC 2.0 notification object with params
sourcepub fn success<I: Into<Id>>(id: I, result: &Value) -> Self
pub fn success<I: Into<Id>>(id: I, result: &Value) -> Self
Creates a JSON-RPC 2.0 success response object
sourcepub fn error<I: Into<Id>>(id: I, error: RpcError) -> Self
pub fn error<I: Into<Id>>(id: I, error: RpcError) -> Self
Creates a JSON-RPC 2.0 error response object
pub fn get_version(&self) -> Option<&str>
pub fn get_id(&self) -> Option<Id>
pub fn get_method(&self) -> Option<&str>
pub fn get_params(&self) -> Option<Params>
pub fn get_result(&self) -> Option<&Value>
pub fn get_error(&self) -> Option<&RpcError>
pub fn parse(input: &str) -> SerdeResult<Self>
pub fn parse_vec(input: &str) -> SerdeResult<Vec<Self>>
Trait Implementations
sourceimpl<'de> Deserialize<'de> for JsonRpc
impl<'de> Deserialize<'de> for JsonRpc
sourcefn 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 StructuralPartialEq for JsonRpc
Auto Trait Implementations
impl RefUnwindSafe for JsonRpc
impl Send for JsonRpc
impl Sync for JsonRpc
impl Unpin for JsonRpc
impl UnwindSafe for JsonRpc
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more