pub struct TypeDef { /* private fields */ }Expand description
Properties for a given expression that express the expected outcome of the expression.
Implementations§
Source§impl TypeDef
impl TypeDef
pub fn kind(&self) -> &Kind
pub fn kind_mut(&mut self) -> &mut Kind
pub fn returns(&self) -> &Kind
pub fn returns_mut(&mut self) -> &mut Kind
pub fn at_path<'a>(&self, path: impl ValuePath<'a>) -> TypeDef
pub fn fallible(self) -> Self
pub fn infallible(self) -> Self
pub fn always_fails(self) -> Self
Sourcepub fn maybe_fallible(self, might_fail: bool) -> Self
pub fn maybe_fallible(self, might_fail: bool) -> Self
Provided for backwards compatibility. Prefer with_fallibility for new code.
pub fn with_fallibility(self, fallibility: Fallibility) -> Self
pub fn pure(self) -> Self
pub fn impure(self) -> Self
pub fn any() -> Self
pub fn bytes() -> Self
pub fn or_bytes(self) -> Self
pub fn integer() -> Self
pub fn or_integer(self) -> Self
pub fn float() -> Self
pub fn or_float(self) -> Self
pub fn boolean() -> Self
pub fn or_boolean(self) -> Self
pub fn timestamp() -> Self
pub fn or_timestamp(self) -> Self
pub fn regex() -> Self
pub fn or_regex(self) -> Self
pub fn null() -> Self
pub fn or_null(self) -> Self
pub fn undefined() -> Self
pub fn or_undefined(self) -> Self
pub fn never() -> Self
pub fn add_null(self) -> Self
pub fn array(collection: impl Into<Collection<Index>>) -> Self
pub fn or_array(self, collection: impl Into<Collection<Index>>) -> Self
Sourcepub fn restrict_array(self) -> Self
pub fn restrict_array(self) -> Self
pub fn object(collection: impl Into<Collection<Field>>) -> Self
pub fn or_object(self, collection: impl Into<Collection<Field>>) -> Self
Sourcepub fn restrict_object(self) -> Self
pub fn restrict_object(self) -> Self
pub fn with_kind(self, kind: Kind) -> Self
pub fn with_returns(self, returns: Kind) -> Self
Sourcepub fn upgrade_undefined(self) -> Self
pub fn upgrade_undefined(self) -> Self
VRL has an interesting property where accessing an undefined value “upgrades” it to a “null” value. This should be used in places those implicit upgrades can occur.
Sourcepub fn collect_subtypes(self) -> Self
pub fn collect_subtypes(self) -> Self
Collects any subtypes that can contain multiple indexed types (array, object) and collects them into a single type for all indexes.
Used for functions that cant determine which indexes of a collection have been used in the result.
pub fn is_fallible(&self) -> bool
pub fn is_infallible(&self) -> bool
pub fn is_pure(&self) -> bool
pub fn is_impure(&self) -> bool
Sourcepub fn fallible_unless(self, kind: impl Into<Kind>) -> Self
pub fn fallible_unless(self, kind: impl Into<Kind>) -> Self
Set the type definition to be fallible if its kind is not contained within the provided kind.
pub fn union(self, other: Self) -> Self
pub fn merge(&mut self, other: Self, strategy: Strategy)
pub fn with_type_inserted<'a>( self, path: impl ValuePath<'a>, other: Self, ) -> Self
pub fn merge_overwrite(self, other: Self) -> Self
Methods from Deref<Target = Kind>§
Sourcepub fn add_bytes(&mut self) -> bool
pub fn add_bytes(&mut self) -> bool
Add the bytes state to the type.
If the type already included this state, the function returns false.
Sourcepub fn add_integer(&mut self) -> bool
pub fn add_integer(&mut self) -> bool
Add the integer state to the type.
If the type already included this state, the function returns false.
Sourcepub fn add_float(&mut self) -> bool
pub fn add_float(&mut self) -> bool
Add the float state to the type.
If the type already included this state, the function returns false.
Sourcepub fn add_boolean(&mut self) -> bool
pub fn add_boolean(&mut self) -> bool
Add the boolean state to the type.
If the type already included this state, the function returns false.
Sourcepub fn add_timestamp(&mut self) -> bool
pub fn add_timestamp(&mut self) -> bool
Add the timestamp state to the type.
If the type already included this state, the function returns false.
Sourcepub fn add_regex(&mut self) -> bool
pub fn add_regex(&mut self) -> bool
Add the regex state to the type.
If the type already included this state, the function returns false.
Sourcepub fn add_null(&mut self) -> bool
pub fn add_null(&mut self) -> bool
Add the null state to the type.
If the type already included this state, the function returns false.
Sourcepub fn add_undefined(&mut self) -> bool
pub fn add_undefined(&mut self) -> bool
Add the null state to the type.
If the type already included this state, the function returns false.
Sourcepub fn add_array(&mut self, collection: impl Into<Collection<Index>>) -> bool
pub fn add_array(&mut self, collection: impl Into<Collection<Index>>) -> bool
Add the array state to the type.
If the type already included this state, the function returns false.
Sourcepub fn add_object(&mut self, collection: impl Into<Collection<Field>>) -> bool
pub fn add_object(&mut self, collection: impl Into<Collection<Field>>) -> bool
Add the object state to the type.
If the type already included this state, the function returns false.
Sourcepub fn remove_bytes(&mut self) -> bool
pub fn remove_bytes(&mut self) -> bool
Remove the bytes state from the type.
If the type previously included this state, true is returned.
Sourcepub fn remove_integer(&mut self) -> bool
pub fn remove_integer(&mut self) -> bool
Remove the integer state from the type.
If the type previously included this state, true is returned.
Sourcepub fn remove_float(&mut self) -> bool
pub fn remove_float(&mut self) -> bool
Remove the float state from the type.
If the type previously included this state, true is returned.
Sourcepub fn remove_boolean(&mut self) -> bool
pub fn remove_boolean(&mut self) -> bool
Remove the boolean state from the type.
If the type previously included this state, true is returned.
Sourcepub fn remove_timestamp(&mut self) -> bool
pub fn remove_timestamp(&mut self) -> bool
Remove the timestamp state from the type.
If the type previously included this state, true is returned.
Sourcepub fn remove_regex(&mut self) -> bool
pub fn remove_regex(&mut self) -> bool
Remove the regex state from the type.
If the type previously included this state, true is returned.
Sourcepub fn remove_null(&mut self) -> bool
pub fn remove_null(&mut self) -> bool
Remove the null state from the type.
If the type previously included this state, true is returned.
Sourcepub fn remove_undefined(&mut self) -> bool
pub fn remove_undefined(&mut self) -> bool
Remove the undefined state from the type.
If the type previously included this state, true is returned.
Sourcepub fn remove_array(&mut self) -> bool
pub fn remove_array(&mut self) -> bool
Remove the array state from the type.
If the type previously included this state, true is returned.
Sourcepub fn remove_object(&mut self) -> bool
pub fn remove_object(&mut self) -> bool
Remove the object state from the type.
If the type previously included this state, true is returned.
Sourcepub fn without_undefined(&self) -> Self
pub fn without_undefined(&self) -> Self
Remove the undefined state from the type, and return it.
Sourcepub fn without_array(&self) -> Self
pub fn without_array(&self) -> Self
Remove the array state from the type, and return it.
Sourcepub fn without_object(&self) -> Self
pub fn without_object(&self) -> Self
Remove the object state from the type, and return it.
Sourcepub fn is_any(&self) -> bool
pub fn is_any(&self) -> bool
Returns true if all type states are valid.
That is, this method only returns true if the object matches all of the known types.
Sourcepub fn is_collection(&self) -> bool
pub fn is_collection(&self) -> bool
Returns true if only collection type states are valid.
Sourcepub fn is_integer(&self) -> bool
pub fn is_integer(&self) -> bool
Returns true if the type is integer.
Sourcepub fn is_boolean(&self) -> bool
pub fn is_boolean(&self) -> bool
Returns true if the type is boolean.
Sourcepub fn is_timestamp(&self) -> bool
pub fn is_timestamp(&self) -> bool
Returns true if the type is timestamp.
Sourcepub fn is_undefined(&self) -> bool
pub fn is_undefined(&self) -> bool
Returns true if the type is undefined.
Sourcepub fn is_superset(&self, other: &Self) -> Result<(), OwnedValuePath>
pub fn is_superset(&self, other: &Self) -> Result<(), OwnedValuePath>
Check if self is a superset of other.
Meaning, if other has a type defined as valid, then self needs to have it defined as
valid as well.
Collection types are recursively checked (meaning, known fields in self also need to be
a superset of other.
§Errors
If the type is not a superset, a path to one field that doesn’t match is returned. This is mostly useful for debugging.
Sourcepub fn intersects(&self, other: &Self) -> bool
pub fn intersects(&self, other: &Self) -> bool
Check if self intersects other.
Returns true if there are type states common to both self and other.
Sourcepub fn contains_bytes(&self) -> bool
pub fn contains_bytes(&self) -> bool
Returns true if the type is at least bytes.
Sourcepub fn contains_integer(&self) -> bool
pub fn contains_integer(&self) -> bool
Returns true if the type is at least integer.
Sourcepub fn contains_float(&self) -> bool
pub fn contains_float(&self) -> bool
Returns true if the type is at least float.
Sourcepub fn contains_boolean(&self) -> bool
pub fn contains_boolean(&self) -> bool
Returns true if the type is at least boolean.
Sourcepub fn contains_timestamp(&self) -> bool
pub fn contains_timestamp(&self) -> bool
Returns true if the type is at least timestamp.
Sourcepub fn contains_regex(&self) -> bool
pub fn contains_regex(&self) -> bool
Returns true if the type is at least regex.
Sourcepub fn contains_null(&self) -> bool
pub fn contains_null(&self) -> bool
Returns true if the type is at least null.
Sourcepub fn contains_undefined(&self) -> bool
pub fn contains_undefined(&self) -> bool
Returns true if the type is at least undefined.
Sourcepub fn contains_any_defined(&self) -> bool
pub fn contains_any_defined(&self) -> bool
Returns true if the type can be any type other than undefined
Sourcepub fn contains_array(&self) -> bool
pub fn contains_array(&self) -> bool
Returns true if the type is at least array.
Sourcepub fn contains_object(&self) -> bool
pub fn contains_object(&self) -> bool
Returns true if the type is at least object.
Sourcepub fn contains_primitive(&self) -> bool
pub fn contains_primitive(&self) -> bool
Returns true if the type contains at least one non-collection type.
Sourcepub fn as_object(&self) -> Option<&Collection<Field>>
pub fn as_object(&self) -> Option<&Collection<Field>>
Get the inner object collection.
This returns None if the type is not known to be an object.
Sourcepub fn as_object_mut(&mut self) -> Option<&mut Collection<Field>>
pub fn as_object_mut(&mut self) -> Option<&mut Collection<Field>>
Get a mutable reference to the inner object collection.
This returns None if the type is not known to be an object.
Sourcepub fn as_array(&self) -> Option<&Collection<Index>>
pub fn as_array(&self) -> Option<&Collection<Index>>
Get the inner array collection.
This returns None if the type is not known to be an array.
Sourcepub fn as_array_mut(&mut self) -> Option<&mut Collection<Index>>
pub fn as_array_mut(&mut self) -> Option<&mut Collection<Index>>
Get a mutable reference to the inner array collection.
This returns None if the type is not known to be an array.
Sourcepub fn get<'a>(&self, path: impl ValuePath<'a>) -> Self
pub fn get<'a>(&self, path: impl ValuePath<'a>) -> Self
Returns the type of a value that is retrieved from a certain path.
This has the same behavior as Value::get, including
the implicit conversion of “undefined” to “null.
If you want the type without the implicit type conversion,
use Kind::at_path instead.
Sourcepub fn at_path<'a>(&self, path: impl ValuePath<'a>) -> Self
pub fn at_path<'a>(&self, path: impl ValuePath<'a>) -> Self
This retrieves the Kind at a given path. There is a subtle difference
between this and Kind::get where this function does not convert undefined to null.
It is viewing the type of a value in-place, before it is retrieved.
Sourcepub fn insert<'a>(&mut self, path: impl ValuePath<'a>, kind: Self)
pub fn insert<'a>(&mut self, path: impl ValuePath<'a>, kind: Self)
Insert the Kind at the given path within self.
This has the same behavior as Value::insert.
Sourcepub fn set_at_path<'a>(&mut self, path: impl ValuePath<'a>, kind: Self)
pub fn set_at_path<'a>(&mut self, path: impl ValuePath<'a>, kind: Self)
Set the Kind at the given path within self.
There is a subtle difference
between this and Kind::insert where this function does not convert undefined to null.
Sourcepub fn insert_recursive<'a, 'b>(
&'a mut self,
iter: impl Iterator<Item = BorrowedSegment<'b>> + Clone,
kind: Self,
)
pub fn insert_recursive<'a, 'b>( &'a mut self, iter: impl Iterator<Item = BorrowedSegment<'b>> + Clone, kind: Self, )
Insert the Kind at the given path within self.
This has the same behavior as Value::insert.
§Panics
Object/Array not present in self.
Sourcepub fn remove(&mut self, path: &OwnedValuePath, prune: bool) -> Self
pub fn remove(&mut self, path: &OwnedValuePath, prune: bool) -> Self
Removes the Kind at the given path within self.
This has the same behavior as Value::remove.
Sourcepub fn debug_info(&self) -> ObjectMap
pub fn debug_info(&self) -> ObjectMap
Returns a tree representation of Kind, in a more human readable format.
This is for debugging / development purposes only.
Sourcepub fn merge(&mut self, other: Self, strategy: Strategy)
pub fn merge(&mut self, other: Self, strategy: Strategy)
Merge other into self, using the provided Strategy.
Sourcepub fn merge_keep(&mut self, other: Self, overwrite: bool)
pub fn merge_keep(&mut self, other: Self, overwrite: bool)
Merge other into self, optionally overwriting on conflicts.
Sourcepub fn canonicalize(&self) -> Self
pub fn canonicalize(&self) -> Self
Returns a Kind type in a standard / simple representation.
Trait Implementations§
impl Eq for TypeDef
impl StructuralPartialEq for TypeDef
Auto Trait Implementations§
impl Freeze for TypeDef
impl RefUnwindSafe for TypeDef
impl Send for TypeDef
impl Sync for TypeDef
impl Unpin for TypeDef
impl UnwindSafe for TypeDef
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,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<Source, Target> OctetsInto<Target> for Sourcewhere
Target: OctetsFrom<Source>,
impl<Source, Target> OctetsInto<Target> for Sourcewhere
Target: OctetsFrom<Source>,
type Error = <Target as OctetsFrom<Source>>::Error
§fn try_octets_into(
self,
) -> Result<Target, <Source as OctetsInto<Target>>::Error>
fn try_octets_into( self, ) -> Result<Target, <Source as OctetsInto<Target>>::Error>
§fn octets_into(self) -> Targetwhere
Self::Error: Into<Infallible>,
fn octets_into(self) -> Targetwhere
Self::Error: Into<Infallible>,
§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg] or
a color-specific method, such as [OwoColorize::green], Read more§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg] or
a color-specific method, such as [OwoColorize::on_yellow], Read more