use derive_more::From;
use serde::{Deserialize, Serialize};
use serde_json::value::RawValue;
use std::sync::Arc;
pub type Meta = serde_json::Map<String, serde_json::Value>;
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(transparent)]
#[non_exhaustive]
pub struct ExtRequest {
#[serde(skip)] pub method: Arc<str>,
#[cfg_attr(feature = "schemars", schemars(with = "serde_json::Value"))]
pub params: Arc<RawValue>,
}
impl ExtRequest {
#[must_use]
pub fn new(method: impl Into<Arc<str>>, params: Arc<RawValue>) -> Self {
Self {
method: method.into(),
params,
}
}
}
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[derive(Debug, Clone, Serialize, Deserialize, From)]
#[serde(transparent)]
#[non_exhaustive]
pub struct ExtResponse(
#[cfg_attr(feature = "schemars", schemars(with = "serde_json::Value"))] pub Arc<RawValue>,
);
impl ExtResponse {
#[must_use]
pub fn new(params: Arc<RawValue>) -> Self {
Self(params)
}
}
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(transparent)]
#[non_exhaustive]
pub struct ExtNotification {
#[serde(skip)] pub method: Arc<str>,
#[cfg_attr(feature = "schemars", schemars(with = "serde_json::Value"))]
pub params: Arc<RawValue>,
}
impl ExtNotification {
#[must_use]
pub fn new(method: impl Into<Arc<str>>, params: Arc<RawValue>) -> Self {
Self {
method: method.into(),
params,
}
}
}