| 49 | } |
| 50 | |
| 51 | pub fn build(mut self) -> LspsService { |
| 52 | self.supported_protocols.sort(); |
| 53 | self.supported_protocols.dedup(); |
| 54 | let supported_protocols: Vec<u8> = self |
| 55 | .supported_protocols |
| 56 | .into_iter() |
| 57 | .filter(|&p| p != 0) |
| 58 | .collect(); |
| 59 | |
| 60 | let protocols_for_rpc = supported_protocols.clone(); |
| 61 | self.router_builder.register( |
| 62 | "lsps0.list_protocols", |
| 63 | move |_p: Lsps0listProtocolsRequest| { |
| 64 | let protocols = protocols_for_rpc.clone(); |
| 65 | async move { Ok(Lsps0listProtocolsResponse { protocols }) } |
| 66 | }, |
| 67 | ); |
| 68 | |
| 69 | let router = self.router_builder.build(); |
| 70 | |
| 71 | LspsService { |
| 72 | router, |
| 73 | supported_protocols, |
| 74 | } |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | #[cfg(test)] |