aiken/crates/aiken-lsp/src/cast.rs

22 lines
541 B
Rust

use crate::error::Error;
pub fn cast_request<R>(request: lsp_server::Request) -> Result<R::Params, Error>
where
R: lsp_types::request::Request,
R::Params: serde::de::DeserializeOwned,
{
let (_, params) = request.extract(R::METHOD)?;
Ok(params)
}
pub fn cast_notification<N>(notification: lsp_server::Notification) -> Result<N::Params, Error>
where
N: lsp_types::notification::Notification,
N::Params: serde::de::DeserializeOwned,
{
let params = notification.extract::<N::Params>(N::METHOD)?;
Ok(params)
}