Skip to main content

Kind

Enum Kind 

Source
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

Source

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.

Source

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

Source

pub const REVISION: u16 = 1u16

The revision number of this type, as declared via #[revisioned(revision = N)].

Source§

impl Kind

Source

pub fn of<T: HasKind>() -> Kind

Returns the kind of a type.

Source

pub fn is_any(&self) -> bool

Returns true if this type is an any

Source

pub fn is_record(&self) -> bool

Returns true if this type is a record

Source

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.

Source

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.

Source

pub fn can_be_none(&self) -> bool

Returns true if this type is optional

Source

pub fn contains_literal(&self) -> bool

Returns true if this type is a literal, or contains a literal

Source

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.

Source

pub fn inner_kind(&self) -> Option<Kind>

Source

pub fn allows_nested_kind(&self, path: &[Part], kind: &Kind) -> bool

Source

pub fn flatten(self) -> Vec<Kind>

Source

pub fn either(kinds: Vec<Kind>) -> Kind

Source

pub fn option(kind: Kind) -> Kind

Trait Implementations§

Source§

impl Clone for Kind

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Kind

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Kind

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl DeserializeRevisioned for Kind

Source§

fn deserialize_revisioned<R: Read>(reader: &mut R) -> Result<Self, Error>

Deserializes a new instance of the struct from the specified reader.
Source§

impl Display for Kind

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Kind

Source§

impl From<&Kind> for Box<Kind>

Source§

fn from(v: &Kind) -> Self

Converts to this type from the input type.
Source§

impl From<Kind> for Kind

Source§

fn from(v: Kind) -> Self

Converts to this type from the input type.
Source§

impl From<Kind> for Kind

Source§

fn from(v: Kind) -> Self

Converts to this type from the input type.
Source§

impl From<Kind> for Kind

Source§

fn from(v: PublicKind) -> Self

Converts to this type from the input type.
Source§

impl From<Kind> for PublicKind

Source§

fn from(v: Kind) -> Self

Converts to this type from the input type.
Source§

impl Hash for Kind

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl InfoStructure for Kind

Source§

impl PartialEq for Kind

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Revisioned for Kind

Source§

fn revision() -> u16

Returns the current revision of this type.
Source§

fn type_id() -> TypeId
where Self: 'static,

Returns the type id of this type.
Source§

impl SerializeRevisioned for Kind

Source§

fn serialize_revisioned<W: Write>(&self, writer: &mut W) -> Result<(), Error>

Serializes the struct using the specified writer.
Source§

impl SkipCheckRevisioned for Kind

Source§

impl SkipRevisioned for Kind

Source§

fn skip_revisioned<R: Read>(reader: &mut R) -> Result<(), Error>

Source§

fn skip_revisioned_slice(reader: &mut SliceReader<'_>) -> Result<(), Error>

Consume through bytes backed by SliceReader without allocating a buffer for bulk segments. Read more
Source§

impl StructuralPartialEq for Kind

Source§

impl ToSql for Kind

Source§

fn fmt_sql(&self, f: &mut String, fmt: SqlFormat)

Format the type to a SQL string.
Source§

fn to_sql(&self) -> String

Convert the type to a SQL string.
Source§

fn to_sql_pretty(&self) -> String

Convert the type to a pretty-printed SQL string with indentation.
Source§

impl<V: Visitor> Visit<V> for Kind

Source§

fn visit(&self, this: &mut V) -> Result<(), V::Error>

Source§

impl<V: MutVisitor> VisitMut<V> for Kind

Source§

fn visit_mut(&mut self, this: &mut V) -> Result<(), V::Error>

Source§

impl WalkRevisioned for Kind

Source§

type Walker<'r, R: BorrowedReader + 'r> = KindWalker<'r, R>

Walker produced by walk_revisioned. Read more
Source§

fn walk_revisioned<'r, R: BorrowedReader>( reader: &'r mut R, ) -> Result<Self::Walker<'r, R>, Error>

Read the type’s revision-level prefix and return a walker positioned at the start of the body. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<U> As for U

Source§

fn as_<T>(self) -> T
where T: CastFrom<U>, U: Sized,

Casts self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SetEntry<T> for T
where T: Hash + Eq,

Source§

fn into_owned(self) -> T

Source§

fn equal(&self, other: &T) -> bool

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

Source§

fn is_within(&self, b: &G2) -> bool