Skip to main content

wasm_capability_contract/component/entity/
component_manifest.rs

1//! [`ComponentManifest`] — identity, limits, and declared capabilities of one component.
2
3use serde::{Deserialize, Serialize};
4
5use crate::ResourceLimits;
6
7/// Declares what a Wasm component is, what it declares it needs to run.
8///
9/// Checked by a real `ComponentValidator` implementor before the
10/// component's route is ever registered — a component whose manifest
11/// fails validation must never reach the host's dispatch engine.
12///
13/// The one `entity` in this crate: `component_id` is a stable identity
14/// that outlives changes to contract version or anything else here, so
15/// equality is by `component_id` alone (see [`PartialEq`] below), not
16/// full structural equality the way a `vo`/`dto` compares.
17#[derive(Debug, Clone, Serialize, Deserialize)]
18pub struct ComponentManifest {
19    /// Stable identifier for this component, independent of version.
20    pub component_id: String,
21    /// The byte-ABI contract version this component was compiled against.
22    pub contract_version: String,
23    /// Name of the component's exported handler function.
24    pub handler_export: String,
25    /// Resource bounds the host must enforce for this component.
26    pub resource_limits: ResourceLimits,
27    /// Capability names this component declares it needs (e.g.
28    /// `"some-capability"`). Anything not also present in the route's
29    /// granted `Vec<CapabilityGrant>` is denied — ADR-001's
30    /// deny-by-default posture.
31    pub capabilities: Vec<String>,
32}
33
34/// Identity-based, not structural: two manifests with the same
35/// `component_id` are the same component even if every other field
36/// differs (e.g. a redeploy that bumps `contract_version`) -- the
37/// entity persists across such changes.
38impl PartialEq for ComponentManifest {
39    fn eq(&self, other: &Self) -> bool {
40        self.component_id == other.component_id
41    }
42}
43
44impl Eq for ComponentManifest {}