pub struct LsBuilder<M, Args: Initializer> {
pub args: Args,
pub client: LspClient,
pub events: HashMap<TypeId, Box<dyn for<'a> Fn(ServiceState<'a, Args, Args::S>, &LspClient, Event) -> Result<()>>>,
pub command_handlers: HashMap<&'static str, Box<dyn Fn(&mut Args::S, &LspClient, RequestId, Vec<Value>) -> ScheduledResult>>,
pub notif_handlers: HashMap<&'static str, Box<dyn Fn(&mut Args::S, Value) -> LspResult<()>>>,
pub req_handlers: HashMap<&'static str, Box<dyn Fn(&mut Args::S, &LspClient, RequestId, Value) -> ScheduledResult>>,
pub resource_handlers: HashMap<Arc<Path>, Box<dyn Fn(&mut Args::S, &LspClient, RequestId, Vec<Value>) -> ScheduledResult>>,
/* private fields */
}
Expand description
The builder pattern for the language server.
Fields§
§args: Args
The extra initialization arguments.
client: LspClient
The client surface for the implementing language server.
events: HashMap<TypeId, Box<dyn for<'a> Fn(ServiceState<'a, Args, Args::S>, &LspClient, Event) -> Result<()>>>
The event handlers.
command_handlers: HashMap<&'static str, Box<dyn Fn(&mut Args::S, &LspClient, RequestId, Vec<Value>) -> ScheduledResult>>
The command handlers.
notif_handlers: HashMap<&'static str, Box<dyn Fn(&mut Args::S, Value) -> LspResult<()>>>
The notification handlers.
req_handlers: HashMap<&'static str, Box<dyn Fn(&mut Args::S, &LspClient, RequestId, Value) -> ScheduledResult>>
The LSP request handlers.
resource_handlers: HashMap<Arc<Path>, Box<dyn Fn(&mut Args::S, &LspClient, RequestId, Vec<Value>) -> ScheduledResult>>
The resource handlers.
Implementations§
Source§impl<Args: Initializer> LsBuilder<DapMessage, Args>where
Args::S: 'static,
impl<Args: Initializer> LsBuilder<DapMessage, Args>where
Args::S: 'static,
Sourcepub fn with_command_(
self,
cmd: &'static str,
handler: fn(srv: &mut Args::S, req_id: RequestId, args: Vec<JsonValue>) -> ScheduledResult,
) -> Self
pub fn with_command_( self, cmd: &'static str, handler: fn(srv: &mut Args::S, req_id: RequestId, args: Vec<JsonValue>) -> ScheduledResult, ) -> Self
Registers an raw event handler.
Sourcepub fn with_command<R: Serialize + 'static>(
self,
cmd: &'static str,
handler: fn(srv: &mut Args::S, args: Vec<JsonValue>) -> SchedulableResponse<R>,
) -> Self
pub fn with_command<R: Serialize + 'static>( self, cmd: &'static str, handler: fn(srv: &mut Args::S, args: Vec<JsonValue>) -> SchedulableResponse<R>, ) -> Self
Registers an async command handler.
Sourcepub fn with_raw_request<R: IRequest>(
self,
handler: fn(srv: &mut Args::S, req_id: RequestId, args: JsonValue) -> ScheduledResult,
) -> Self
pub fn with_raw_request<R: IRequest>( self, handler: fn(srv: &mut Args::S, req_id: RequestId, args: JsonValue) -> ScheduledResult, ) -> Self
Registers a raw request handler that handlers a kind of untyped lsp request.
Sourcepub fn with_request_<R: IRequest>(
self,
handler: fn(_: &mut Args::S, _: RequestId, _: R::Arguments) -> ScheduledResult,
) -> Self
pub fn with_request_<R: IRequest>( self, handler: fn(_: &mut Args::S, _: RequestId, _: R::Arguments) -> ScheduledResult, ) -> Self
Registers an raw request handler that handlers a kind of typed lsp request.
Sourcepub fn with_request<R: IRequest>(
self,
handler: fn(srv: &mut Args::S, args: R::Arguments) -> SchedulableResponse<R::Response>,
) -> Self
pub fn with_request<R: IRequest>( self, handler: fn(srv: &mut Args::S, args: R::Arguments) -> SchedulableResponse<R::Response>, ) -> Self
Registers a typed request handler.
Source§impl<Args: Initializer> LsBuilder<LspMessage, Args>where
Args::S: 'static,
impl<Args: Initializer> LsBuilder<LspMessage, Args>where
Args::S: 'static,
Sourcepub fn with_command_(
self,
cmd: &'static str,
handler: fn(srv: &mut Args::S, req_id: RequestId, args: Vec<JsonValue>) -> ScheduledResult,
) -> Self
pub fn with_command_( self, cmd: &'static str, handler: fn(srv: &mut Args::S, req_id: RequestId, args: Vec<JsonValue>) -> ScheduledResult, ) -> Self
Registers an raw event handler.
Sourcepub fn with_command<R: Serialize + 'static>(
self,
cmd: &'static str,
handler: fn(srv: &mut Args::S, args: Vec<JsonValue>) -> SchedulableResponse<R>,
) -> Self
pub fn with_command<R: Serialize + 'static>( self, cmd: &'static str, handler: fn(srv: &mut Args::S, args: Vec<JsonValue>) -> SchedulableResponse<R>, ) -> Self
Registers an async command handler.
Sourcepub fn with_notification_<R: Notif>(
self,
handler: fn(srv: &mut Args::S, args: JsonValue) -> LspResult<()>,
) -> Self
pub fn with_notification_<R: Notif>( self, handler: fn(srv: &mut Args::S, args: JsonValue) -> LspResult<()>, ) -> Self
Registers an untyped notification handler.
Sourcepub fn with_notification<R: Notif>(
self,
handler: fn(srv: &mut Args::S, args: R::Params) -> LspResult<()>,
) -> Self
pub fn with_notification<R: Notif>( self, handler: fn(srv: &mut Args::S, args: R::Params) -> LspResult<()>, ) -> Self
Registers a typed notification handler.
Sourcepub fn with_raw_request<R: Req>(
self,
handler: fn(srv: &mut Args::S, req_id: RequestId, args: JsonValue) -> ScheduledResult,
) -> Self
pub fn with_raw_request<R: Req>( self, handler: fn(srv: &mut Args::S, req_id: RequestId, args: JsonValue) -> ScheduledResult, ) -> Self
Registers a raw request handler that handlers a kind of untyped lsp request.
Sourcepub fn with_request_<R: Req>(
self,
handler: fn(_: &mut Args::S, _: RequestId, _: R::Params) -> ScheduledResult,
) -> Self
pub fn with_request_<R: Req>( self, handler: fn(_: &mut Args::S, _: RequestId, _: R::Params) -> ScheduledResult, ) -> Self
Registers an raw request handler that handlers a kind of typed lsp request.
Sourcepub fn with_request<R: Req>(
self,
handler: fn(srv: &mut Args::S, args: R::Params) -> SchedulableResponse<R::Result>,
) -> Self
pub fn with_request<R: Req>( self, handler: fn(srv: &mut Args::S, args: R::Params) -> SchedulableResponse<R::Result>, ) -> Self
Registers a typed request handler.
Source§impl<M, Args: Initializer> LsBuilder<M, Args>where
Args::S: 'static,
impl<M, Args: Initializer> LsBuilder<M, Args>where
Args::S: 'static,
Sourcepub fn with_event<T: Any>(
self,
ins: &T,
handler: impl for<'a> Fn(ServiceState<'a, Args, Args::S>, T) -> Result<()> + 'static,
) -> Self
pub fn with_event<T: Any>( self, ins: &T, handler: impl for<'a> Fn(ServiceState<'a, Args, Args::S>, T) -> Result<()> + 'static, ) -> Self
Registers an event handler.
Sourcepub fn with_resource_(
self,
path: Arc<Path>,
handler: fn(srv: &mut Args::S, req_id: RequestId, args: Vec<JsonValue>) -> ScheduledResult,
) -> Self
pub fn with_resource_( self, path: Arc<Path>, handler: fn(srv: &mut Args::S, req_id: RequestId, args: Vec<JsonValue>) -> ScheduledResult, ) -> Self
Registers a raw resource handler.
Sourcepub fn with_resource(
self,
path: &'static str,
handler: fn(_: &mut Args::S, _: Vec<JsonValue>) -> AnySchedulableResponse,
) -> Self
pub fn with_resource( self, path: &'static str, handler: fn(_: &mut Args::S, _: Vec<JsonValue>) -> AnySchedulableResponse, ) -> Self
Registers an async resource handler.