pub enum Envelope {
Request(Request),
Notification(Notification),
Response(Response),
}Variants§
Implementations§
Source§impl Envelope
impl Envelope
Sourcepub fn parse(bytes: &[u8]) -> Result<Self>
pub fn parse(bytes: &[u8]) -> Result<Self>
Parse one strict JSON-RPC object, rejecting duplicate keys, non-objects, unknown envelope members, invalid IDs, and excessive nesting.
Sourcepub fn parse_classified(bytes: &[u8]) -> Result<Self, (Error, ErrorKind)>
pub fn parse_classified(bytes: &[u8]) -> Result<Self, (Error, ErrorKind)>
Parse, reporting the error kind the frame should be answered with.
Malformed bytes yield parse_error; anything that parsed as JSON but
broke a rule above it (duplicate keys, nesting depth, unknown members,
invalid IDs, method and params shape) yields invalid_request. Callers
that must answer with an error kind use this instead of re-parsing the
frame with a laxer parser to guess which layer failed.
pub fn to_vec(&self) -> Result<Vec<u8>>
Trait Implementations§
impl StructuralPartialEq for Envelope
Auto Trait Implementations§
impl Freeze for Envelope
impl RefUnwindSafe for Envelope
impl Send for Envelope
impl Sync for Envelope
impl Unpin for Envelope
impl UnsafeUnpin for Envelope
impl UnwindSafe for Envelope
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