mirror of
https://github.com/mistricky/codesnap.nvim.git
synced 2025-01-15 05:17:30 -08:00
31 lines
450 B
Rust
31 lines
450 B
Rust
use serde::Serialize;
|
|
|
|
#[derive(Serialize)]
|
|
pub struct Event<T>
|
|
where
|
|
T: Serialize,
|
|
{
|
|
name: String,
|
|
data: T,
|
|
}
|
|
|
|
impl<T> Event<T>
|
|
where
|
|
T: Serialize,
|
|
{
|
|
pub fn new(name: &str, data: T) -> Event<T> {
|
|
Event {
|
|
name: name.to_string(),
|
|
data,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl<T> Into<String> for Event<T>
|
|
where
|
|
T: Serialize,
|
|
{
|
|
fn into(self) -> String {
|
|
serde_json::to_string(&self).unwrap()
|
|
}
|
|
}
|