pub struct LspReader<R> { /* private fields */ }Expand description
One-message-at-a-time async reader.
Wraps any AsyncBufRead. Construct via
LspReader::new from an AsyncRead (we wrap in BufReader
internally) or use LspReader::from_buf_reader when the
caller already has buffering.
Implementations§
Source§impl<R: AsyncBufRead + Unpin> LspReader<R>
impl<R: AsyncBufRead + Unpin> LspReader<R>
Sourcepub fn from_buf_reader(inner: R) -> Self
pub fn from_buf_reader(inner: R) -> Self
Wrap an already-buffered reader. Use this when the caller has tuned the buffer size or shares one across multiple streams.
Sourcepub async fn read_message(&mut self) -> Result<Option<Message>, CodecError>
pub async fn read_message(&mut self) -> Result<Option<Message>, CodecError>
Read one complete LSP message. Resolves to:
Ok(Some(msg))– a message arrived.Ok(None)– the stream closed cleanly between messages (graceful shutdown, server exited).Err(_)– mid-message I/O error or framing/decode failure. The caller should tear the transport down.
Auto Trait Implementations§
impl<R> Freeze for LspReader<R>where
R: Freeze,
impl<R> RefUnwindSafe for LspReader<R>where
R: RefUnwindSafe,
impl<R> Send for LspReader<R>where
R: Send,
impl<R> Sync for LspReader<R>where
R: Sync,
impl<R> Unpin for LspReader<R>where
R: Unpin,
impl<R> UnsafeUnpin for LspReader<R>where
R: UnsafeUnpin,
impl<R> UnwindSafe for LspReader<R>where
R: UnwindSafe,
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more