pub trait Converter: Send + Sync {
// Required methods
fn id(&self) -> ConverterId;
fn input(&self) -> &TypeExpr;
fn output(&self) -> &TypeExpr;
fn cost(&self) -> u64;
fn convert(&self, value: Value) -> DataResult<Value>;
// Provided methods
fn feature_flags(&self) -> &[String] { ... }
fn requires_gpu(&self) -> bool { ... }
}Expand description
Trait implemented by converters between value types.
use daedalus_data::convert::{Converter, ConverterId};
use daedalus_data::errors::DataResult;
use daedalus_data::model::{TypeExpr, Value, ValueType};
struct Noop;
impl Converter for Noop {
fn id(&self) -> ConverterId { ConverterId("noop".into()) }
fn input(&self) -> &TypeExpr { &TypeExpr::Scalar(ValueType::Int) }
fn output(&self) -> &TypeExpr { &TypeExpr::Scalar(ValueType::Int) }
fn cost(&self) -> u64 { 0 }
fn convert(&self, value: Value) -> DataResult<Value> { Ok(value) }
}