appcore_gateway/capability.rs
1// =============================================================================
2// #######
3// ### ### F: capability.rs
4// ## ## ## ## P: AppCore-Runtime
5// ## ##
6// C: 2026/07/26 08:53:09 by dnettoRaw
7// ## ## ## ## U: 2026/07/26 08:53:09 by dnettoRaw
8// ########### S: 1.0.1-rc.8
9// =============================================================================
10
11//! Capability definitions inside the Gateway context.
12
13use appcore_types::{
14 CapabilityDescriptor, CapabilityMode, CapabilityName, CapabilityRequirements,
15 CapabilityVisibility,
16};
17use serde::{Deserialize, Serialize};
18
19/// Stable Runtime infrastructure capability implemented by the Gateway.
20pub const GATEWAY_RUNTIME_CAPABILITY: &str = "runtime.gateway";
21
22/// Builds the descriptor consumed by the Runtime capability policy when the
23/// Gateway deployment adapter is selected.
24pub fn gateway_capability_descriptor() -> crate::GatewayResult<CapabilityDescriptor> {
25 Ok(CapabilityDescriptor::new(
26 CapabilityName::new(GATEWAY_RUNTIME_CAPABILITY)?,
27 env!("CARGO_PKG_VERSION"),
28 CapabilityMode::Stream,
29 CapabilityVisibility::Tenant,
30 )
31 .with_requirements(CapabilityRequirements {
32 requires_leader: false,
33 read_only: false,
34 idempotency_required: false,
35 }))
36}
37
38/// Simplified descriptor for a capability registered at the gateway.
39#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
40pub struct GatewayCapability {
41 /// Unique capability name.
42 pub name: CapabilityName,
43 /// SemVer compatibility version string.
44 pub version: String,
45}
46
47impl GatewayCapability {
48 /// Creates a new gateway capability.
49 pub fn new(name: CapabilityName, version: impl Into<String>) -> Self {
50 Self {
51 name,
52 version: version.into(),
53 }
54 }
55}