Skip to main content

Server

Struct Server 

Source
pub struct Server { /* private fields */ }
Expand description

Stateful LSP server. One instance per stdio session; the document store owns the in-memory snapshot of every open buffer.

§Examples

use noyalib_lsp::Server;
let server = Server::new();
assert_eq!(server.open_document_count(), 0);

Implementations§

Source§

impl Server

Source

pub fn new() -> Self

Construct a fresh server with an empty document store.

§Examples
use noyalib_lsp::Server;
let server = Server::new();
assert_eq!(server.open_document_count(), 0);
Source

pub fn open_document_count(&self) -> usize

Number of currently-open documents. Useful for tests that assert the server’s internal state.

§Examples
use noyalib_lsp::Server;
assert_eq!(Server::new().open_document_count(), 0);
Source

pub fn document(&self, uri: &str) -> Option<&str>

Snapshot of an open document, or None if the URI is not known.

§Examples
use noyalib_lsp::Server;
let server = Server::new();
assert_eq!(server.document("file:///nope.yaml"), None);
Source

pub fn handle_message(&mut self, raw: &str) -> HandleOutcome

Process one parsed JSON-RPC line and return the resulting reply / notifications. The stdio loop in main calls this per LSP message; tests call it with crafted strings.

§Examples
use noyalib_lsp::Server;
let mut server = Server::new();
let req = r#"{"jsonrpc":"2.0","method":"initialize","id":1,"params":{}}"#;
let outcome = server.handle_message(req);
assert!(outcome.reply.is_some());

Trait Implementations§

Source§

impl Debug for Server

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Server

Source§

fn default() -> Server

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T