pub trait Admits {
// Required method
fn admits(&self, value: &Value) -> Result<(), Mismatch>;
}Expand description
Required Methods§
Sourcefn admits(&self, value: &Value) -> Result<(), Mismatch>
fn admits(&self, value: &Value) -> Result<(), Mismatch>
Whether value is one this type admits, and where it stops being one
when it is not.
The check follows this type’s own recursion rather than looking only
at the outermost constructor, because a shallow check would admit an
Array<Int> where an Array<String> was declared and the schema says
more than “an array”. HostType::Any admits everything, which is
not a hole: it is the type of an operation whose meaning does not
depend on which value it was given — the work clock.timeout bounds,
the body clock.every repeats — so there is nothing there to check.
HostType::Named is checked by name. Every value carries the
qualified type it was built with and a crate::host::ResourceHandle
carries the module and kind it was issued for, so the comparison is
one the value itself can answer, with no registry to consult and no
second lookup on a path every host call takes. What that leaves
unchecked is a TypeSchema’s fields: a value calling itself an
http.Response is taken at its word about what is inside it. See ADR
0013’s amendment for why that line is drawn there.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".