pub trait Resource:
Send
+ Sync
+ 'static {
// Required methods
fn resource_id(&self) -> &str;
fn resource_type() -> &'static str
where Self: Sized;
}Expand description
A resource that can be protected by a Capability.
Resources are typed: Report, CodeFile, InfraConfig, etc. The type
parameter on Capability<P, R> binds the capability to a specific resource
type, preventing a write-cap on Report from being used on CodeFile.
Implementors provide:
resource_id()— a runtime identifier (URI, path, UUID) for audit logs.resource_type()— a static type name for error messages.
Required Methods§
Sourcefn resource_id(&self) -> &str
fn resource_id(&self) -> &str
Runtime identifier for this resource instance (e.g. "reports/q1-2025").
Sourcefn resource_type() -> &'static strwhere
Self: Sized,
fn resource_type() -> &'static strwhere
Self: Sized,
Static type name (e.g. "Report"). Used in error messages and codegen.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".