sync_ls

Struct LsBuilder

Source
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,

Source

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.

Source

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.

Source

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.

Source

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.

Source

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,

Source

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.

Source

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.

Source

pub fn with_notification_<R: Notif>( self, handler: fn(srv: &mut Args::S, args: JsonValue) -> LspResult<()>, ) -> Self

Registers an untyped notification handler.

Source

pub fn with_notification<R: Notif>( self, handler: fn(srv: &mut Args::S, args: R::Params) -> LspResult<()>, ) -> Self

Registers a typed notification handler.

Source

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.

Source

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.

Source

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,

Source

pub fn new(args: Args, client: LspClient) -> Self

Creates a new language server builder.

Source

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.

Source

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.

Source

pub fn with_resource( self, path: &'static str, handler: fn(_: &mut Args::S, _: Vec<JsonValue>) -> AnySchedulableResponse, ) -> Self

Registers an async resource handler.

Source

pub fn build(self) -> LsDriver<M, Args>

Builds the language server driver.

Auto Trait Implementations§

§

impl<M, Args> Freeze for LsBuilder<M, Args>
where Args: Freeze,

§

impl<M, Args> !RefUnwindSafe for LsBuilder<M, Args>

§

impl<M, Args> !Send for LsBuilder<M, Args>

§

impl<M, Args> !Sync for LsBuilder<M, Args>

§

impl<M, Args> Unpin for LsBuilder<M, Args>
where Args: Unpin, M: Unpin,

§

impl<M, Args> !UnwindSafe for LsBuilder<M, Args>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> ErasedDestructor for T
where T: 'static,