gluon-lang/lsp-types

Add the Serialize trait to Request::Params

Closed this issue · 1 comments

(Caveat: I'm new to Rust so I may have an incorrect understanding of traits or something. Please correct me if so.)

I'm trying to use this crate to implement a lsp client for my editor. I'm trying to things in some good way and am attempting to write a method that I will serialize stuff for me. It looks like:

use lsp_types::request::Request;

pub fn marshal<R: Request>(params: R::Params) -> Result<Vec<u8>> {
	let mut s = Vec::new();
	let msg = serde_json::to_writer(&mut s, &params)?;
	Ok(s)
}

The serde_json call complains because params doesn't implement the serde::ser::Serialize trait. I think this is true because it's not listed in the Request trait. However, all of the Params actually do implement that trait, so I think it can safely be added to the Request trait. Is this the case?

I think this is ok, just being conservative/forgot about it. There was an equivalent issue for Deserialize #70 so it ought to be Serialize + DeserializeOwned