Converter

Trait Converter 

Source
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) }
}

Required Methods§

Source

fn id(&self) -> ConverterId

Source

fn input(&self) -> &TypeExpr

Source

fn output(&self) -> &TypeExpr

Source

fn cost(&self) -> u64

Source

fn convert(&self, value: Value) -> DataResult<Value>

Provided Methods§

Implementors§

Source§

impl<F> Converter for FnConverter<F>
where F: Fn(Value) -> DataResult<Value> + Send + Sync + 'static,