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
impl Server
Sourcepub fn new() -> Self
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);Sourcepub fn open_document_count(&self) -> usize
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);Sourcepub fn document(&self, uri: &str) -> Option<&str>
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);Sourcepub fn handle_message(&mut self, raw: &str) -> HandleOutcome
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§
Auto Trait Implementations§
impl Freeze for Server
impl RefUnwindSafe for Server
impl Send for Server
impl Sync for Server
impl Unpin for Server
impl UnsafeUnpin for Server
impl UnwindSafe for Server
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