Trait Cast Copy item path Source pub trait Cast {
type Output ;
// Required method
fn cast (&self, target_dtype: &DType ) -> VortexResult <Self::Output >;
}Expand description Trait for casting vectors and scalars to different data types.
§ Nullability Requirements
Casting a source that contains null values to a non-nullable target dtype will return an error.
This invariant is not checked by the common helper functions, so each implementation is
responsible for enforcing it.
§ Common Casting Behaviors
All implementations share these behaviors:
Identity : Casting to the same dtype (with compatible nullability) returns a clone.
Null casting : Any all-null vector can be cast to DType::Null , and any null scalar
can be cast to a NullScalar .
Extension types : Casting to an extension type delegates to casting to its storage dtype.
The output type after casting.
Cast the vector or scalar to the specified data type.
Dispatches to the contained Scalar or Vector cast implementation.
Dispatches to the underlying DScalar<D> implementation.
Dispatches to the underlying DVector<D> implementation.
Dispatches to the underlying PScalar<T>
implementation.
Dispatches to the underlying PVector<T>
implementation.
Dispatches to the underlying typed scalar implementation.
Dispatches to the underlying typed vector implementation.
Casts to Bool (identity) or Primitive (as 0/1).
Casts to Bool (identity) or Primitive (as 0/1).
Casts to FixedSizeList (identity with same element dtype, size, and compatible nullability).
Casts to FixedSizeList (identity with same element dtype, size, and compatible nullability).
Casts to List (identity with same element dtype and compatible nullability).
Casts to List (identity with same element dtype and compatible nullability).
Casts to any nullable target type by creating a null scalar.
Casts to any nullable target type by creating an all-null vector.
Casts to Struct (identity with same fields and compatible nullability).
Casts to Struct (identity with same fields and compatible nullability).
Casts to Decimal with potentially different precision and native type.
Casts to Decimal (identity with same precision/scale and compatible nullability).
Cast a primitive vector to a different primitive type.
Cast a primitive scalar to a different primitive type.
Casts to Utf8 or Binary (identity cast with compatible nullability).
Casts to Utf8 or Binary (identity cast with compatible nullability).