pub struct AlgorithmSignature {
pub output_fields: Vec<Field>,
pub docs: String,
pub args: Vec<NamedArgType>,
pub slices: Vec<SliceReq>,
}Expand description
Static signature of an algorithm.
args and slices are additive, defaulted fields (construct with
..Default::default()): existing providers that leave them empty keep the
legacy untyped config_json contract unchanged. A provider that declares
args opts into host-side arity/type validation before it runs (proposal
§4.6 / decision D7); a provider that declares slices opts into load-time
capability-slice version negotiation (proposal §4.3 / decision D6).
Fields§
§output_fields: Vec<Field>Output column schema.
docs: StringMarkdown docs.
args: Vec<NamedArgType>Declared positional arguments, in call order.
Empty (the default) preserves the legacy behavior: arguments arrive as a
raw positional config_json array the provider parses itself. When
non-empty, the host validates arity and coerces each positional argument
against the declared NamedArgType before the provider runs, filling
omitted trailing arguments from their declared defaults.
slices: Vec<SliceReq>Required capability slices, checked at load time.
Empty (the default) means the algorithm targets only the always-present
graph-compute@1 surface. A declared SliceReq whose version the host
does not provide fails the load with a clear error (0x86A) rather than a
mysterious runtime “unknown kernel op” trap.
Implementations§
Source§impl AlgorithmSignature
impl AlgorithmSignature
Sourcepub fn check_slices(&self, host_slices: &[(&str, u16)]) -> Result<(), FnError>
pub fn check_slices(&self, host_slices: &[(&str, u16)]) -> Result<(), FnError>
Validates the declared capability slices against host_slices.
Each requirement must be met by a host slice of the same name whose
version is at least the requested one. Pass HOST_CAPABILITY_SLICES for
the production surface.
§Errors
Returns 0x86A (SliceVersionMismatch) naming the first requirement the
host cannot satisfy (proposal §4.3 / §12, decision D6).
Sourcepub fn coerce_config_json(&self, config_json: &str) -> Result<String, FnError>
pub fn coerce_config_json(&self, config_json: &str) -> Result<String, FnError>
Validates and normalizes a positional config_json array against args.
When args is empty this is a no-op returning config_json unchanged, so
providers on the legacy untyped contract are unaffected. Otherwise it
parses the positional JSON array and, per declared argument: rejects a
present value whose JSON kind is incompatible with the declared
ArgType, errors on a missing argument
that has no default, and appends the declared default for an omitted
trailing argument. Extra positional arguments beyond the declared arity
are rejected. The returned JSON array is what the provider then parses, so
it observes defaults already filled in.
§Errors
Returns 0x86E (argument arity/type violation) with a message naming the
offending argument (proposal §4.6, decision D7).
Trait Implementations§
Source§impl Clone for AlgorithmSignature
impl Clone for AlgorithmSignature
Source§fn clone(&self) -> AlgorithmSignature
fn clone(&self) -> AlgorithmSignature
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AlgorithmSignature
impl Debug for AlgorithmSignature
Source§impl Default for AlgorithmSignature
impl Default for AlgorithmSignature
Source§fn default() -> AlgorithmSignature
fn default() -> AlgorithmSignature
Auto Trait Implementations§
impl !RefUnwindSafe for AlgorithmSignature
impl !UnwindSafe for AlgorithmSignature
impl Freeze for AlgorithmSignature
impl Send for AlgorithmSignature
impl Sync for AlgorithmSignature
impl Unpin for AlgorithmSignature
impl UnsafeUnpin for AlgorithmSignature
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more