pub struct FrameCodec { /* private fields */ }Expand description
Frame codec for encoding/decoding JSON-RPC messages
Uses Content-Length header framing similar to LSP/MCP.
Implementations§
Source§impl FrameCodec
impl FrameCodec
Sourcepub fn with_max_size(max_message_size: usize) -> Self
pub fn with_max_size(max_message_size: usize) -> Self
Create a frame codec with a custom max message size
Sourcepub fn encode(&self, message: &JsonRpcMessage) -> Result<Vec<u8>>
pub fn encode(&self, message: &JsonRpcMessage) -> Result<Vec<u8>>
Encode a message into a framed byte vector
Format: Content-Length: <length>\r\n\r\n<json>
Sourcepub fn encode_to_writer<W: Write>(
&self,
writer: &mut W,
message: &JsonRpcMessage,
) -> Result<()>
pub fn encode_to_writer<W: Write>( &self, writer: &mut W, message: &JsonRpcMessage, ) -> Result<()>
Encode a message and write to a writer
Sourcepub fn decode_from_buffer<'a>(
&self,
buffer: &'a [u8],
) -> Result<(&'a [u8], Option<JsonRpcMessage>)>
pub fn decode_from_buffer<'a>( &self, buffer: &'a [u8], ) -> Result<(&'a [u8], Option<JsonRpcMessage>)>
Decode a message from a complete buffer
Returns the remaining unconsumed bytes and the parsed message. Returns Ok((remaining, None)) if more data is needed.
Sourcepub fn max_message_size(&self) -> usize
pub fn max_message_size(&self) -> usize
Get the maximum message size
Trait Implementations§
Source§impl Debug for FrameCodec
impl Debug for FrameCodec
Source§impl Default for FrameCodec
impl Default for FrameCodec
Source§fn default() -> FrameCodec
fn default() -> FrameCodec
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for FrameCodec
impl RefUnwindSafe for FrameCodec
impl Send for FrameCodec
impl Sync for FrameCodec
impl Unpin for FrameCodec
impl UnsafeUnpin for FrameCodec
impl UnwindSafe for FrameCodec
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