1use std::{collections::HashMap, fmt::Display, pin::Pin};
2
3use lsp_types::{Diagnostic, MessageType, Url};
4
5#[derive(Debug)]
6pub struct Resp {
7 pub headers: Vec<(String, String)>,
8 pub body: String,
9 pub status: u16,
10}
11
12#[tower_lsp::async_trait]
13pub trait Client: Clone + ClientSync {
14 async fn log_message<M: Display + Sync + Send + 'static>(&self, ty: MessageType, msg: M) -> ();
15 async fn publish_diagnostics(
16 &self,
17 uri: Url,
18 diags: Vec<Diagnostic>,
19 version: Option<i32>,
20 ) -> ();
21}
22
23pub trait ClientSync {
24 fn spawn<F: std::future::Future<Output = ()> + Send + 'static>(&self, fut: F);
25 fn fetch(
26 &self,
27 url: &str,
28 headers: &HashMap<String, String>,
29 ) -> Pin<Box<dyn Send + std::future::Future<Output = Result<Resp, String>>>>;
30}