clay_core/map/map.rs
1use crate::{
2 prelude::*,
3 map::Chain,
4};
5
6
7/// Some invertible mapping that could be applied to vectors.
8pub trait Map: Pack + Instance<MapClass> {
9 /// Create a new mapping where this one is followed by another one.
10 fn chain<M: Map>(self, other: M) -> Chain<Self, M> {
11 Chain::<Self, M>::new(self, other)
12 }
13}
14
15/// Device interface for mapping.
16pub enum MapClass {}
17impl Class for MapClass {
18 fn name() -> String {
19 "map".to_string()
20 }
21 fn methods() -> Vec<String> {
22 [
23 "rel",
24 "abs",
25 "rel_inv",
26 "abs_inv",
27 "norm",
28 ]
29 .iter()
30 .map(|m| m.to_string())
31 .collect()
32 }
33}