pub enum Kind {
Show 25 variants
Any,
None,
Null,
Bool,
Bytes,
Datetime,
Decimal,
Duration,
Float,
Int,
Number,
Object,
String,
Uuid,
Regex,
Table(Vec<TableName>),
Record(Vec<TableName>),
Geometry(Vec<GeometryKind>),
Either(Vec<Kind>),
Set(Box<Kind>, Option<u64>),
Array(Box<Kind>, Option<u64>),
Function(Option<Vec<Kind>>, Option<Box<Kind>>),
Range,
Literal(KindLiteral),
File(Vec<String>),
}Expand description
The kind, or data type, of a value or field.
Variants§
Any
The most generic type, can be anything.
None
None type.
Null
Null type.
Bool
Boolean type.
Bytes
Bytes type.
Datetime
Datetime type.
Decimal
Decimal type.
Duration
Duration type.
Float
64-bit floating point type.
Int
64-bit signed integer type.
Number
Number type, can be either a float, int or decimal. This is the most generic type for numbers.
Object
Object type.
String
String type.
Uuid
UUID type.
Regex
Regular expression type.
Table(Vec<TableName>)
A table type.
Record(Vec<TableName>)
A record type.
Geometry(Vec<GeometryKind>)
A geometry type.
The vec contains the geometry types as strings, for example "point" or
"polygon".
Either(Vec<Kind>)
An either type. Can be any of the kinds in the vec.
Set(Box<Kind>, Option<u64>)
A set type.
Array(Box<Kind>, Option<u64>)
An array type.
Function(Option<Vec<Kind>>, Option<Box<Kind>>)
A function type. The first option is the argument types, the second is the optional return type.
Range
A range type.
Literal(KindLiteral)
A literal type.
The literal type is used to represent a type that can only be a single
value. For example, "a" is a literal type which can only ever be
"a". This can be used in the Kind::Either type to represent an
enum.
File(Vec<String>)
A file type.
If the kind was specified without a bucket the vec will be empty.
So <file> is just Kind::File(Vec::new())
Implementations§
Source§impl Kind
impl Kind
Sourcepub fn walk_revisioned_variant_name(
wire_revision: u16,
discriminant: u32,
) -> Option<&'static str>
pub fn walk_revisioned_variant_name( wire_revision: u16, discriminant: u32, ) -> Option<&'static str>
Resolve a wire discriminant at wire_revision to the variant
identifier at that revision. Returns None if no such variant
exists at that revision.
Generated by the revisioned derive.
Sourcepub fn walk_revisioned_variant_table(
wire_revision: u16,
) -> &'static [(&'static str, u32)]
pub fn walk_revisioned_variant_table( wire_revision: u16, ) -> &'static [(&'static str, u32)]
Variant name + discriminant pairs at wire_revision. Returns
an empty slice if the revision is unknown. Generated by the
revisioned derive.
Source§impl Kind
impl Kind
Sourcepub fn reference_can_target(&self, table: &TableName) -> bool
pub fn reference_can_target(&self, table: &TableName) -> bool
Returns true if a DEFINE FIELD ... REFERENCE declared with this kind
could hold a record id belonging to table.
A reference key is only ever written (by process_reference_clause)
when a reference field holds a record id, and the field’s declared kind
constrains which tables those ids may belong to via TYPE coercion. So
this answers, from the schema alone, whether records in table can have
incoming reference keys — used by the DELETE purge path to skip the
per-record reference scan when they provably cannot.
The matched shapes mirror exactly the kinds accepted for reference
fields by [crate::sql::statements::DefineFieldStatement::validate_reference_options]:
record<..>, array/set of those, option<..> (an Either
containing None), and literal arrays of those. An untyped record
(Kind::Record with an empty table list) can hold a record of any
table, so it always matches. Kind::Any is rejected for reference
fields at definition time but is treated as a match here defensively —
erring towards running the scan is always safe.
Sourcepub fn collect_reference_target_tables(
&self,
out: &mut HashSet<TableName>,
) -> bool
pub fn collect_reference_target_tables( &self, out: &mut HashSet<TableName>, ) -> bool
Collects the concrete record tables a REFERENCE field of this kind can
target into out, returning true if the kind can target any table
(an untyped record / record<>, or — defensively — any), in which
case out is not exhaustive and every table must be treated as
potentially referenced.
This is the enumerating dual of Self::reference_can_target: it lets a
caller build a database-wide set of referenceable tables once (e.g. the
memoized DELETE purge gate) rather than re-deciding per table. The
matched shapes are identical to that method’s.
Sourcepub fn can_be_none(&self) -> bool
pub fn can_be_none(&self) -> bool
Returns true if this type is optional
Sourcepub fn contains_literal(&self) -> bool
pub fn contains_literal(&self) -> bool
Returns true if this type is a literal, or contains a literal
Sourcepub fn allows_sub_fields(&self) -> bool
pub fn allows_sub_fields(&self) -> bool
Returns true if this type permits access to named sub-fields.
This covers object, any, literal object types (e.g. { key: string }),
and union types where every variant other than none and null permits
sub-field access and at least one variant does.
pub fn inner_kind(&self) -> Option<Kind>
pub fn allows_nested_kind(&self, path: &[Part], kind: &Kind) -> bool
pub fn flatten(self) -> Vec<Kind>
pub fn either(kinds: Vec<Kind>) -> Kind
pub fn option(kind: Kind) -> Kind
Trait Implementations§
Source§impl DeserializeRevisioned for Kind
impl DeserializeRevisioned for Kind
impl Eq for Kind
Source§impl From<Kind> for Kind
impl From<Kind> for Kind
Source§fn from(v: PublicKind) -> Self
fn from(v: PublicKind) -> Self
Source§impl From<Kind> for PublicKind
impl From<Kind> for PublicKind
Source§impl Revisioned for Kind
impl Revisioned for Kind
Source§impl SerializeRevisioned for Kind
impl SerializeRevisioned for Kind
Source§impl SkipCheckRevisioned for Kind
impl SkipCheckRevisioned for Kind
Source§impl SkipRevisioned for Kind
impl SkipRevisioned for Kind
fn skip_revisioned<R: Read>(reader: &mut R) -> Result<(), Error>
Source§fn skip_revisioned_slice(reader: &mut SliceReader<'_>) -> Result<(), Error>
fn skip_revisioned_slice(reader: &mut SliceReader<'_>) -> Result<(), Error>
SliceReader without allocating a buffer for bulk segments. Read moreimpl StructuralPartialEq for Kind
Source§impl<V: MutVisitor> VisitMut<V> for Kind
impl<V: MutVisitor> VisitMut<V> for Kind
Source§impl WalkRevisioned for Kind
impl WalkRevisioned for Kind
Source§type Walker<'r, R: BorrowedReader + 'r> = KindWalker<'r, R>
type Walker<'r, R: BorrowedReader + 'r> = KindWalker<'r, R>
walk_revisioned. Read moreSource§fn walk_revisioned<'r, R: BorrowedReader>(
reader: &'r mut R,
) -> Result<Self::Walker<'r, R>, Error>
fn walk_revisioned<'r, R: BorrowedReader>( reader: &'r mut R, ) -> Result<Self::Walker<'r, R>, Error>
Auto Trait Implementations§
impl Freeze for Kind
impl RefUnwindSafe for Kind
impl Send for Kind
impl Sync for Kind
impl Unpin for Kind
impl UnsafeUnpin for Kind
impl UnwindSafe for Kind
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.