pub struct ResourceSpec {
pub resource: ResourceMeta,
pub crud: CrudMapping,
pub action: Option<ActionMapping>,
pub identity: IdentityConfig,
pub fields: BTreeMap<String, FieldOverride>,
pub read_mapping: BTreeMap<String, String>,
}Expand description
Top-level resource specification loaded from TOML.
Two flavours are supported:
- CRUD (default):
kind = "crud"or absent — requires[crud]+[identity]tables. Resolved viacrate::resolve_resource. - Action (RPC-style):
kind = "action"— requires[action]table; MUST NOT have[crud]/[identity]. Resolved viacrate::resolve_action.
Both crud and identity default to empty placeholders so an action
TOML can omit them entirely. Use ResourceSpec::is_action before
dispatching to the CRUD resolver — calling resolve_resource on an
action spec will fail loudly.
Fields§
§resource: ResourceMetaResource metadata (name, description, category, kind).
crud: CrudMappingCRUD operation mappings.
Defaults to an empty placeholder so kind = "action" specs (which
have no [crud] table) parse cleanly. CRUD callers must verify
via ResourceSpec::is_action before reading the empty struct.
action: Option<ActionMapping>Action mapping for RPC-style endpoints. Required when kind = "action".
identity: IdentityConfigIdentity and import configuration.
Defaults to an empty placeholder so action specs parse without an
[identity] table.
fields: BTreeMap<String, FieldOverride>Per-field overrides (skip, computed, sensitive, etc.).
read_mapping: BTreeMap<String, String>Mapping from API response JSON paths to field names.
Implementations§
Source§impl ResourceSpec
impl ResourceSpec
Source§impl ResourceSpec
impl ResourceSpec
Sourcepub fn load(path: &Path) -> Result<Self, IacForgeError>
pub fn load(path: &Path) -> Result<Self, IacForgeError>
Load a resource spec from a TOML file.
Delegates to ConfigLoader::load.
§Errors
Returns an error if the file can’t be read or parsed.
Sourcepub fn validate(&self, api: &Spec) -> Result<(), IacForgeError>
pub fn validate(&self, api: &Spec) -> Result<(), IacForgeError>
Validate the resource spec against an OpenAPI spec.
Dispatches on ResourceSpec::is_action:
- CRUD specs validate create/read/delete (+ optional update / read response) schemas and the create endpoint path.
- Action specs validate the action endpoint + request schema (and the optional response schema).
§Errors
Returns validation errors if schemas are missing or endpoints don’t exist.
Trait Implementations§
Source§impl Clone for ResourceSpec
impl Clone for ResourceSpec
Source§fn clone(&self) -> ResourceSpec
fn clone(&self) -> ResourceSpec
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more