pub struct LspCodec { /* private fields */ }Expand description
LSP wire protocol codec implementing Content-Length framing.
This codec handles encoding and decoding of LSP Message types using
the Content-Length header framing specified by the LSP wire protocol.
§Encoding
Messages are serialized to JSON, then prefixed with a Content-Length header:
Content-Length: {byte_length}\r\n\r\n{json_body}§Decoding
The decoder handles partial reads by maintaining state between calls:
- Returns
Ok(None)if the header is incomplete - Returns
Ok(None)if the body is incomplete - Returns
Ok(Some(message))when a complete message is available
§Thread Safety
LspCodec maintains internal parsing state and should not be shared between
concurrent readers. Use one codec instance per direction (read/write) or
use Framed which handles this correctly.
Implementations§
Trait Implementations§
Source§impl Decoder for LspCodec
impl Decoder for LspCodec
Source§fn decode(
&mut self,
src: &mut BytesMut,
) -> Result<Option<Self::Item>, Self::Error>
fn decode( &mut self, src: &mut BytesMut, ) -> Result<Option<Self::Item>, Self::Error>
Attempts to decode a frame from the provided buffer of bytes. Read more
Auto Trait Implementations§
impl Freeze for LspCodec
impl RefUnwindSafe for LspCodec
impl Send for LspCodec
impl Sync for LspCodec
impl Unpin for LspCodec
impl UnsafeUnpin for LspCodec
impl UnwindSafe for LspCodec
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