use indexmap::IndexMap; use instructions::Instruction; use petgraph::graph::DiGraph; use types::Type; trait Node { fn inputs() -> IndexMap; fn outputs() -> IndexMap; } struct NodeGraph { graph: DiGraph, } struct TypedEdge { from: String, to: String, typ: Type, } mod instructions { //! This is the lowest level of the IR, the one the executor will use. use std::path::Path; use indexmap::{indexmap, IndexMap}; pub enum Instruction { // File handling LoadFile, SaveFile, ColorMatrix, PosMatrix, Blend, SplitChannels, } impl Instruction { fn inputs(&self) -> IndexMap { match self { Instruction::LoadFile => indexmap! { "path" => Type::Path }, Instruction::SaveFile => indexmap! { "path" => Type::Path }, Instruction::ColorMatrix => indexmap! { "image" => Type::ImageData, "matrix" => Type::Mat(4,5) }, Instruction::PosMatrix => indexmap! { "image" => Type::ImageData, "matrix" => Type::Mat(2, 3), }, Instruction::Blend => todo!(), Instruction::SplitChannels => todo!(), } } fn outputs(&self) -> IndexMap { match self { Instruction::LoadFile => indexmap! { "image" => Type::ImageData }, Instruction::SaveFile => indexmap! {}, Instruction::ColorMatrix => indexmap! { "resut" => Type::ImageData }, Instruction::PosMatrix => todo!(), Instruction::Blend => todo!(), Instruction::SplitChannels => todo!(), } } } } mod types { pub enum Type { // TODO: later do lower level type system for this stuff? // Image(Size, PixelType), // // image data for processing. // // always PixelType::Rgba32F // ImageData(Size), // // stuff that's still to be generated, not sized and no pixeltype // ProceduralImage, ImageData, Text, Integer, Float, Double, Path, Bool, Vec( // length, u8, ), Mat( // Rows u8, // Columns u8, ), } // pub struct Size { // width: u16, // height: u16, // } // Pixel types. Taken from variants [here](https://docs.rs/image/latest/image/pub enum.DynamicImage.html). // pub enum PixelType { // Luma8, // LumaA8, // Rgb8, // Rgba8, // Luma16, // LumaA16, // Rgb16, // Rgba16, // Rgb32F, // #[default] // Rgba32F, // } }