pub struct Codec { /* private fields */ }Expand description
Codec for encoding/decoding JSON-RPC messages.
Implementations§
Source§impl Codec
impl Codec
Sourcepub fn max_message_size(&self) -> usize
pub fn max_message_size(&self) -> usize
Returns the maximum allowed message size in bytes.
Sourcepub fn set_max_message_size(&mut self, size: usize)
pub fn set_max_message_size(&mut self, size: usize)
Sets the maximum allowed message size in bytes.
Sourcepub fn encode_request(
&self,
request: &JsonRpcRequest,
) -> Result<Vec<u8>, CodecError>
pub fn encode_request( &self, request: &JsonRpcRequest, ) -> Result<Vec<u8>, CodecError>
Sourcepub fn encode_response(
&self,
response: &JsonRpcResponse,
) -> Result<Vec<u8>, CodecError>
pub fn encode_response( &self, response: &JsonRpcResponse, ) -> Result<Vec<u8>, CodecError>
Sourcepub fn decode(&mut self, data: &[u8]) -> Result<Vec<JsonRpcMessage>, CodecError>
pub fn decode(&mut self, data: &[u8]) -> Result<Vec<JsonRpcMessage>, CodecError>
Decodes bytes into a message, returning any complete messages.
Incomplete data is buffered for the next call.
§Errors
Returns an error if a complete line fails to parse or if the buffer exceeds the limit.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Codec
impl RefUnwindSafe for Codec
impl Send for Codec
impl Sync for Codec
impl Unpin for Codec
impl UnwindSafe for Codec
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).