pub struct WhereFieldSchema { /* private fields */ }Expand description
The where keys a type declares, alongside their casts.
§Why this is not just FieldTypeMap
FieldTypeMap cannot distinguish “this type has no fields” from “this
type was not found” — both produce an empty map, and the generator reads
empty as “no type information, skip the casts”. Reusing it as an allowlist
would therefore fail open on a missing type, or — if inverted — fail
closed on every schema with no field metadata.
So the “cannot adjudicate” state is a distinct value here (known: None)
rather than a property of an empty collection. Every consumer has to name
that branch explicitly.
Implementations§
Source§impl WhereFieldSchema
impl WhereFieldSchema
Sourcepub fn casts_only(casts: Arc<FieldTypeMap>) -> WhereFieldSchema
pub fn casts_only(casts: Arc<FieldTypeMap>) -> WhereFieldSchema
A schema that cannot adjudicate field names: casts only, no allowlist.
This is the honest constructor for a caller that has type information but no type definition — fuzzers, benchmarks, and the wire path.
Sourcepub fn with_known_keys(
casts: Arc<FieldTypeMap>,
known: HashMap<String, WhereFieldInfo>,
) -> WhereFieldSchema
pub fn with_known_keys( casts: Arc<FieldTypeMap>, known: HashMap<String, WhereFieldInfo>, ) -> WhereFieldSchema
A schema that can adjudicate its top level and nothing below it.
For callers that know the entry type’s keys but cannot name what a
relation points at. See with_relations for the
compiled-schema path.
Sourcepub fn with_relations(
casts: Arc<FieldTypeMap>,
known: HashMap<String, WhereFieldInfo>,
relations: Arc<HashMap<String, Arc<HashMap<String, WhereFieldInfo>>>>,
) -> WhereFieldSchema
pub fn with_relations( casts: Arc<FieldTypeMap>, known: HashMap<String, WhereFieldInfo>, relations: Arc<HashMap<String, Arc<HashMap<String, WhereFieldInfo>>>>, ) -> WhereFieldSchema
A schema that can adjudicate every level a nested predicate reaches.
relations maps a declared type name to that type’s where keys, so a
key at depth n is scored against the type the path actually arrived at
rather than passed through unchecked.
Sourcepub const fn casts(&self) -> &Arc<FieldTypeMap> ⓘ
pub const fn casts(&self) -> &Arc<FieldTypeMap> ⓘ
The declared casts.
Sourcepub fn lookup(&self, snake_key: &str) -> Option<&WhereFieldInfo>
pub fn lookup(&self, snake_key: &str) -> Option<&WhereFieldInfo>
What the schema knows about snake_key, or None when it cannot
adjudicate or the key is undeclared — use Self::can_adjudicate to
tell those apart.
Sourcepub const fn can_adjudicate(&self) -> bool
pub const fn can_adjudicate(&self) -> bool
Whether the schema carries enough information to reject an unknown key.
Sourcepub fn declared_names(&self) -> Vec<&str>
pub fn declared_names(&self) -> Vec<&str>
Declared names, for “did you mean” hints.
Sourcepub fn root_level(&self) -> Option<&HashMap<String, WhereFieldInfo>>
pub fn root_level(&self) -> Option<&HashMap<String, WhereFieldInfo>>
The entry level a where object is parsed against.
Trait Implementations§
Source§impl Clone for WhereFieldSchema
impl Clone for WhereFieldSchema
Source§fn clone(&self) -> WhereFieldSchema
fn clone(&self) -> WhereFieldSchema
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more