pub struct Kind { /* private fields */ }Expand description
The type (kind) of a given value.
This struct tracks the known states a type can have. By allowing one type to have multiple states, the type definition can be progressively refined.
Implementations§
Source§impl Kind
impl Kind
Sourcepub fn any() -> Self
pub fn any() -> Self
The “any” type state.
This state implies all states for the type are valid. There is no known information that can be gleaned from the type.
Sourcepub fn json() -> Self
pub fn json() -> Self
The “json” type state.
This state is similar to any, except that it excludes any types that can’t be represented
in a native JSON-type (such as timestamp and regex).
Sourcepub fn array(collection: impl Into<Collection<Index>>) -> Self
pub fn array(collection: impl Into<Collection<Index>>) -> Self
The “array” type state.
Sourcepub fn object(collection: impl Into<Collection<Field>>) -> Self
pub fn object(collection: impl Into<Collection<Field>>) -> Self
The “object” type state.
Sourcepub fn any_object() -> Self
pub fn any_object() -> Self
An object that can have any fields.
Source§impl Kind
impl Kind
Sourcepub const fn or_integer(self) -> Self
pub const fn or_integer(self) -> Self
Add the integer state to the type.
Sourcepub const fn or_boolean(self) -> Self
pub const fn or_boolean(self) -> Self
Add the boolean state to the type.
Sourcepub const fn or_timestamp(self) -> Self
pub const fn or_timestamp(self) -> Self
Add the timestamp state to the type.
Sourcepub const fn or_undefined(self) -> Self
pub const fn or_undefined(self) -> Self
Add the undefined state to the type.
Sourcepub fn or_array(self, collection: impl Into<Collection<Index>>) -> Self
pub fn or_array(self, collection: impl Into<Collection<Index>>) -> Self
Add the array state to the type.
Sourcepub fn or_object(self, collection: impl Into<Collection<Field>>) -> Self
pub fn or_object(self, collection: impl Into<Collection<Field>>) -> Self
Add the object state to the type.
Source§impl Kind
impl 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.
Source§impl Kind
impl Kind
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.
Source§impl Kind
impl Kind
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.
Source§impl Kind
impl Kind
Sourcepub const fn is_any(&self) -> bool
pub const 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 const fn is_collection(&self) -> bool
pub const fn is_collection(&self) -> bool
Returns true if only collection type states are valid.
Sourcepub const fn is_integer(&self) -> bool
pub const fn is_integer(&self) -> bool
Returns true if the type is integer.
Sourcepub const fn is_boolean(&self) -> bool
pub const fn is_boolean(&self) -> bool
Returns true if the type is boolean.
Sourcepub const fn is_timestamp(&self) -> bool
pub const fn is_timestamp(&self) -> bool
Returns true if the type is timestamp.
Sourcepub const fn is_undefined(&self) -> bool
pub const 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 const fn intersects(&self, other: &Self) -> bool
pub const fn intersects(&self, other: &Self) -> bool
Check if self intersects other.
Returns true if there are type states common to both self and other.
Source§impl Kind
impl Kind
Sourcepub const fn contains_bytes(&self) -> bool
pub const fn contains_bytes(&self) -> bool
Returns true if the type is at least bytes.
Sourcepub const fn contains_integer(&self) -> bool
pub const fn contains_integer(&self) -> bool
Returns true if the type is at least integer.
Sourcepub const fn contains_float(&self) -> bool
pub const fn contains_float(&self) -> bool
Returns true if the type is at least float.
Sourcepub const fn contains_boolean(&self) -> bool
pub const fn contains_boolean(&self) -> bool
Returns true if the type is at least boolean.
Sourcepub const fn contains_timestamp(&self) -> bool
pub const fn contains_timestamp(&self) -> bool
Returns true if the type is at least timestamp.
Sourcepub const fn contains_regex(&self) -> bool
pub const fn contains_regex(&self) -> bool
Returns true if the type is at least regex.
Sourcepub const fn contains_null(&self) -> bool
pub const fn contains_null(&self) -> bool
Returns true if the type is at least null.
Sourcepub const fn contains_undefined(&self) -> bool
pub const fn contains_undefined(&self) -> bool
Returns true if the type is at least undefined.
Sourcepub const fn contains_any_defined(&self) -> bool
pub const fn contains_any_defined(&self) -> bool
Returns true if the type can be any type other than undefined
Sourcepub const fn contains_array(&self) -> bool
pub const fn contains_array(&self) -> bool
Returns true if the type is at least array.
Sourcepub const fn contains_object(&self) -> bool
pub const fn contains_object(&self) -> bool
Returns true if the type is at least object.
Sourcepub const fn contains_primitive(&self) -> bool
pub const fn contains_primitive(&self) -> bool
Returns true if the type contains at least one non-collection type.
Source§impl Kind
impl Kind
Sourcepub const fn as_object(&self) -> Option<&Collection<Field>>
pub const 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 into_object(self) -> Option<Collection<Field>>
pub fn into_object(self) -> Option<Collection<Field>>
Take an object Collection type out of the Kind.
This returns None if the type is not known to be an object.
Sourcepub const fn as_array(&self) -> Option<&Collection<Index>>
pub const 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 into_array(self) -> Option<Collection<Index>>
pub fn into_array(self) -> Option<Collection<Index>>
Take an array Collection type out of the Kind.
This returns None if the type is not known to be an array.
Sourcepub fn to_primitives(self) -> Self
pub fn to_primitives(self) -> Self
Returns Kind, with non-primitive states removed.
That is, it returns self, but removes the object and array states.
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.
Source§impl Kind
impl Kind
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.
Source§impl Kind
impl Kind
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.
Source§impl Kind
impl Kind
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.
Source§impl Kind
impl Kind
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.
Source§impl Kind
impl Kind
Source§impl Kind
impl Kind
Sourcepub fn canonicalize(&self) -> Self
pub fn canonicalize(&self) -> Self
Returns a Kind type in a standard / simple representation.
Trait Implementations§
Source§impl DefaultValue for Kind
impl DefaultValue for Kind
Source§impl From<Collection<Field>> for Kind
impl From<Collection<Field>> for Kind
Source§fn from(collection: Collection<Field>) -> Self
fn from(collection: Collection<Field>) -> Self
Source§impl From<Collection<Index>> for Kind
impl From<Collection<Index>> for Kind
Source§fn from(collection: Collection<Index>) -> Self
fn from(collection: Collection<Index>) -> Self
Source§impl PartialOrd for Kind
impl PartialOrd for Kind
impl Eq for Kind
Auto Trait Implementations§
impl Freeze for Kind
impl RefUnwindSafe for Kind
impl Send for Kind
impl Sync for Kind
impl Unpin 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,
§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§fn fg_rgb<const R: u8, const G: u8, const B: u8>(
&self,
) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
§fn bg_rgb<const R: u8, const G: u8, const B: u8>(
&self,
) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
§fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
§fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
§fn if_supports_color<'a, Out, ApplyFn>(
&'a self,
stream: impl Into<Stream>,
apply: ApplyFn,
) -> SupportsColorsDisplay<'a, Self, Out, ApplyFn>where
ApplyFn: Fn(&'a Self) -> Out,
fn if_supports_color<'a, Out, ApplyFn>(
&'a self,
stream: impl Into<Stream>,
apply: ApplyFn,
) -> SupportsColorsDisplay<'a, Self, Out, ApplyFn>where
ApplyFn: Fn(&'a Self) -> Out,
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.