File tree Expand file tree Collapse file tree 1 file changed +53
-0
lines changed
Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Original file line number Diff line number Diff line change 11# Build Server Protocol
22
33[ Build Server Protocol] ( https://build-server-protocol.github.io/docs/specification.html ) client, server and type definition in rust.
4+
5+ ## Example
6+
7+ ``` rust
8+ use anyhow :: Result ;
9+ use bsp_server :: {types :: * , * };
10+
11+ fn main () -> Result <()> {
12+ install_tracing (" /tmp/" , " xcodebase-server.log" , false )? ;
13+ let (conn , io_threads ) = Connection :: stdio ();
14+
15+ tracing :: info! (" Started------------------------------" );
16+
17+ let params = conn . initialize (| params | crate :: server :: initialize (& params ). expect (" Initialize" ))? ;
18+
19+ block (conn , params )? ;
20+
21+ io_threads . join ()? ;
22+
23+ tracing :: info! (" Ended ------------------------------" );
24+
25+ Ok (())
26+ }
27+
28+ fn block (conn : Connection , _initialize_params : InitializeBuild ) -> Result <()> {
29+ for msg in & conn . receiver {
30+ match msg {
31+ Message :: Request (req ) => {
32+ use Request :: * ;
33+ match req {
34+ Shutdown (_ ) => {
35+ conn . handle_shutdown (& req )? ;
36+ return Ok (());
37+ }
38+ WorkspaceBuildTargets (id ) => {
39+ conn . send ((id , WorkspaceBuildTargetsResult :: default ()))? ;
40+ }
41+ BuildTargetSources (id , _ ) => {
42+ conn . send ((id , BuildTargetSourcesResult :: default ()))? ;
43+ }
44+ _ => {
45+ tracing :: warn! (" Unable to handle:\ n\ n {:#?}\ n" , req );
46+ conn . send (Response :: method_not_found (req . id (). clone (), "" . into ()))? ;
47+ }
48+ };
49+ }
50+ Message :: Response (_ ) => {}
51+ Message :: Notification (_ ) => {}
52+ };
53+ }
54+ Ok (())
55+ }
56+ ```
You can’t perform that action at this time.
0 commit comments