pub struct LspTransport { /* private fields */ }Expand description
LSP transport layer handling header-content format.
This transport handles the LSP protocol’s header-content message format, parsing Content-Length headers and reading exact message content.
Implementations§
Source§impl LspTransport
impl LspTransport
Sourcepub fn new(stdin: ChildStdin, stdout: ChildStdout) -> Self
pub fn new(stdin: ChildStdin, stdout: ChildStdout) -> Self
Create transport from child process stdio.
§Arguments
stdin- The child process’s stdin handle for sending messagesstdout- The child process’s stdout handle for receiving messages
Sourcepub async fn send(&mut self, message: &Value) -> Result<()>
pub async fn send(&mut self, message: &Value) -> Result<()>
Send message to LSP server.
Formats the message with proper Content-Length header and sends it to the LSP server via stdin.
§Errors
Returns an error if:
- Message serialization fails
- Writing to stdin fails
- Flushing stdin fails
Sourcepub async fn receive(&mut self) -> Result<InboundMessage>
pub async fn receive(&mut self) -> Result<InboundMessage>
Receive next message from LSP server.
Reads headers, extracts Content-Length, reads exact message content, and parses it as either a response or notification.
§Errors
Returns an error if:
- Reading headers fails
- Content-Length header is missing or invalid
- Reading message content fails
- JSON parsing fails
- Message format is invalid
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LspTransport
impl RefUnwindSafe for LspTransport
impl Send for LspTransport
impl Sync for LspTransport
impl Unpin for LspTransport
impl UnwindSafe for LspTransport
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