pub trait VCast: Sized {
type Shared: Send + Sync + 'static;
// Required methods
fn source_type() -> Result<LogicalType>;
fn target_type() -> Result<LogicalType>;
fn cast_row(
shared: &Self::Shared,
input: &VectorRef<'_>,
output: &mut VectorMut<'_>,
row: usize,
) -> UdfResult<()>;
// Provided method
fn implicit_cast_cost() -> i64 { ... }
}Expand description
A DuckDB custom cast: converts values of a source logical type to a target type.
See the callback-containment contract in crate::udf.
Required Associated Types§
Registration-time shared state, available read-only to the cast callback.
Use () if the cast needs none.
Required Methods§
Sourcefn source_type() -> Result<LogicalType>
fn source_type() -> Result<LogicalType>
Sourcefn target_type() -> Result<LogicalType>
fn target_type() -> Result<LogicalType>
Sourcefn cast_row(
shared: &Self::Shared,
input: &VectorRef<'_>,
output: &mut VectorMut<'_>,
row: usize,
) -> UdfResult<()>
fn cast_row( shared: &Self::Shared, input: &VectorRef<'_>, output: &mut VectorMut<'_>, row: usize, ) -> UdfResult<()>
Converts input[row] and writes it to output[row].
§Errors
Returns an error for a value that cannot be converted. Under a normal CAST
the query fails with that message; under TRY_CAST the output row is set to
NULL instead.
Provided Methods§
Sourcefn implicit_cast_cost() -> i64
fn implicit_cast_cost() -> i64
The implicit-cast cost the binder uses to choose this cast (lower = preferred;
a negative value disables implicit application, requiring an explicit CAST).
Defaults to -1 (explicit only).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".