#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct RouteTransportCapabilities {
pub request_types: &'static [&'static str],
pub response_types: &'static [&'static str],
pub default_response_type: &'static str,
pub supports_sequence_response: bool,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct RouteTransportDescriptor {
pub name: &'static str,
pub method: &'static str,
pub path: &'static str,
pub capabilities: RouteTransportCapabilities,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct OpDescriptor {
pub op_id: &'static str,
pub kind: OpKind,
pub input_ty: &'static str,
pub output_ty: &'static str,
pub idempotent_by_default: bool,
pub auth_required: bool,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum OpKind {
Unary,
Sequence,
Subscription,
}
impl OpKind {
pub const fn as_str(&self) -> &'static str {
match self {
OpKind::Unary => "unary",
OpKind::Sequence => "sequence",
OpKind::Subscription => "subscription",
}
}
}
pub fn canonical_request_string(
method: &str,
path: &str,
canonical_query: Option<&str>,
content_type: Option<&str>,
body: &[u8],
) -> String {
let query = canonical_query.unwrap_or_default();
let content_type = content_type.unwrap_or_default();
let body_hex = body
.iter()
.map(|byte| format!("{byte:02x}"))
.collect::<String>();
format!("{method}\n{path}\n{query}\n{content_type}\n{body_hex}")
}