pub struct DispatchMethod { /* private fields */ }Expand description
A single method belonging to a GenericFunction.
Pairs a parameter-shape signature with an executable MethodBody and a
MethodRole; methods are matched against call arguments through the
kernel Shape protocol.
Implementations§
Source§impl DispatchMethod
impl DispatchMethod
Sourcepub fn new(
id: Symbol,
role: MethodRole,
parameter_shapes: Vec<Arc<dyn Shape>>,
body: MethodBody,
) -> Self
pub fn new( id: Symbol, role: MethodRole, parameter_shapes: Vec<Arc<dyn Shape>>, body: MethodBody, ) -> Self
Builds a method from its id, role, parameter shapes, and body.
Sourcepub fn role(&self) -> MethodRole
pub fn role(&self) -> MethodRole
Returns the method’s role in the combination.
Sourcepub fn parameter_shapes(&self) -> &[Arc<dyn Shape>]
pub fn parameter_shapes(&self) -> &[Arc<dyn Shape>]
Returns the parameter shapes this method matches against, in order.
Sourcepub fn hints(&self) -> &[HintMetadata]
pub fn hints(&self) -> &[HintMetadata]
Returns the operation hints attached to this method.
Sourcepub fn with_hint(self, hint: HintMetadata) -> Self
pub fn with_hint(self, hint: HintMetadata) -> Self
Adds an operation hint to this method.
Sourcepub fn with_argument_hint(
self,
argument: Symbol,
detail: impl Into<String>,
) -> Self
pub fn with_argument_hint( self, argument: Symbol, detail: impl Into<String>, ) -> Self
Adds a hint describing one method argument.
Sourcepub fn with_capability_requirement(self, capability: CapabilityName) -> Self
pub fn with_capability_requirement(self, capability: CapabilityName) -> Self
Adds a hint describing a capability requirement.
Sourcepub fn with_codec_safe_form(self, form: Symbol) -> Self
pub fn with_codec_safe_form(self, form: Symbol) -> Self
Adds a hint describing a codec-safe form.
Sourcepub fn with_example(self, example: impl Into<String>) -> Self
pub fn with_example(self, example: impl Into<String>) -> Self
Adds a runnable or displayable operation example.
Sourcepub fn match_args(
&self,
cx: &mut Cx,
args: &[Value],
) -> Result<Option<MethodSpecificity>>
pub fn match_args( &self, cx: &mut Cx, args: &[Value], ) -> Result<Option<MethodSpecificity>>
Tests the method against args, returning its specificity if applicable.
Returns None on arity mismatch or if any parameter shape rejects its
argument; otherwise returns the accumulated MethodSpecificity.
Trait Implementations§
Source§impl Clone for DispatchMethod
impl Clone for DispatchMethod
Source§fn clone(&self) -> DispatchMethod
fn clone(&self) -> DispatchMethod
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more