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