pub struct OpSpec {
pub key: OpKey,
pub subject: Ref,
pub args_shape: Ref,
pub result_shape: Ref,
pub effects: Vec<Symbol>,
pub requires: Vec<CapabilityName>,
}Expand description
The declared contract of an operation: its key, shapes, effects, and required capabilities.
An OpSpec is metadata the kernel checks before dispatch – the
args_shape is validated against the input and the
requires capabilities are demanded from the Cx –
while the concrete behavior lives in the Op that carries it.
Fields§
§key: OpKeyThe interned operation key (namespace:name@vN) this spec describes.
subject: RefThe subject the operation dispatches on.
args_shape: RefThe shape the input is checked against before invocation.
result_shape: RefThe shape the operation promises for its result.
effects: Vec<Symbol>The effect symbols the operation may emit.
requires: Vec<CapabilityName>The capabilities that must be granted before the operation runs.
Implementations§
Source§impl OpSpec
impl OpSpec
Sourcepub fn new(key: OpKey, subject: Ref, args_shape: Ref, result_shape: Ref) -> Self
pub fn new(key: OpKey, subject: Ref, args_shape: Ref, result_shape: Ref) -> Self
Builds a spec with no declared effects or capability requirements.
Sourcepub fn with_effects(self, effects: Vec<Symbol>) -> Self
pub fn with_effects(self, effects: Vec<Symbol>) -> Self
Returns the spec with its effect set replaced.
Sourcepub fn requiring(self, capability: CapabilityName) -> Self
pub fn requiring(self, capability: CapabilityName) -> Self
Returns the spec with one more required capability appended.
Sourcepub fn with_requirements(self, requires: Vec<CapabilityName>) -> Self
pub fn with_requirements(self, requires: Vec<CapabilityName>) -> Self
Returns the spec with its required-capability set replaced.