pub struct SignatureBuilder { /* private fields */ }Expand description
Builder for constructing a Signature.
Enforces that the signature has at least one input and one output field at build time.
Implementations§
Source§impl SignatureBuilder
impl SignatureBuilder
Sourcepub fn input(self, def: FieldDef) -> Self
pub fn input(self, def: FieldDef) -> Self
Add an input field. The field’s kind is set to FieldKind::Input
regardless of what was passed.
Sourcepub fn output(self, def: FieldDef) -> Self
pub fn output(self, def: FieldDef) -> Self
Add an output field. The field’s kind is set to FieldKind::Output
regardless of what was passed.
Sourcepub fn build(self) -> Result<Signature>
pub fn build(self) -> Result<Signature>
Validate and build the signature.
Validation covers: at-least-one input + at-least-one output
(existing); structural validation of every transitively-reachable
FieldType::OneOf and
FieldType::AnyOf field (new) — non-empty
arms, discriminator parallelism with arms, unique tag values, and
arm-shape consistency with the named discriminator property.
Schema-conversion-driven construction (via field_type_from_schema in
typesayer) is validated at conversion time and would not
produce malformed variants here. The validation in this builder is the
safety net for callers that construct FieldType::OneOf / AnyOf
programmatically.
§Errors
Returns PredictError::InvalidSignature if there are no input or
output fields, or if any variant field violates the structural
constraints above.