Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kkharji/build-server-protocol
Rust crate for creating BSP Servers.
https://github.com/kkharji/build-server-protocol
build-server-protocol protocol rpc rpc-library rust
Last synced: 11 days ago
JSON representation
Rust crate for creating BSP Servers.
- Host: GitHub
- URL: https://github.com/kkharji/build-server-protocol
- Owner: kkharji
- Created: 2022-04-20T15:51:55.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-05-26T14:23:33.000Z (over 2 years ago)
- Last Synced: 2025-01-02T06:43:19.766Z (20 days ago)
- Topics: build-server-protocol, protocol, rpc, rpc-library, rust
- Language: Rust
- Homepage: https://docs.rs/bsp-server/0.1.0/bsp_server/
- Size: 152 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Build Server Protocol
State: Working, Unstable
[Build Server Protocol](https://build-server-protocol.github.io/docs/specification.html) client, server and type definition in rust.
## Install```
bsp-server = "0.1.3"
# OR if you want just types
bsp-types = "0.1.3"
```## Example
```rust
use anyhow::Result;
use bsp_server::{types::*, *};fn main() -> Result<()> {
install_tracing("/tmp/", "xcodebase-server.log", false)?;
let (conn, io_threads) = Connection::stdio();tracing::info!("Started------------------------------");
let params = conn.initialize(|params| crate::server::initialize(¶ms).expect("Initialize"))?;
block(conn, params)?;
io_threads.join()?;
tracing::info!("Ended ------------------------------");
Ok(())
}fn block(conn: Connection, _initialize_params: InitializeBuild) -> Result<()> {
for msg in &conn.receiver {
match msg {
Message::Request(req) => {
use Request::*;
match req {
Shutdown(_) => {
conn.handle_shutdown(&req)?;
return Ok(());
}
WorkspaceBuildTargets(id) => {
conn.send((id, WorkspaceBuildTargetsResult::default()))?;
}
BuildTargetSources(id, _) => {
conn.send((id, BuildTargetSourcesResult::default()))?;
}
_ => {
tracing::warn!("Unable to handle:\n\n{:#?}\n", req);
conn.send(Response::method_not_found(req.id().clone(), "".into()))?;
}
};
}
Message::Response(_) => {}
Message::Notification(_) => {}
};
}
Ok(())
}
```