aboutsummaryrefslogtreecommitdiff
path: root/src/system.rs
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2021-03-07 06:32:15 -0700
committerMelody Horn <melody@boringcactus.com>2021-03-07 06:32:15 -0700
commit28a8fb462fa88da300c6cf016ed3c70c402b8dba (patch)
treeb306bc95c4b38a4feba2bb36b5992a2a15c2411c /src/system.rs
parent22acbd09f089aa3e6310791aee14debb139421e4 (diff)
downloadhope-28a8fb462fa88da300c6cf016ed3c70c402b8dba.tar.gz
hope-28a8fb462fa88da300c6cf016ed3c70c402b8dba.zip
add a good-enough-for-now system actor type
Diffstat (limited to 'src/system.rs')
-rw-r--r--src/system.rs31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/system.rs b/src/system.rs
new file mode 100644
index 0000000..7df8af8
--- /dev/null
+++ b/src/system.rs
@@ -0,0 +1,31 @@
+use crate::actor::{Actorful, Slot, Type};
+use crate::number::Number;
+
+pub struct System {
+ pub screen_buffer: Vec<u32>,
+}
+
+impl Actorful for System {
+ fn inputs() -> Vec<Slot> {
+ let nonnegative_int = Type::NumberInRange {
+ min: Some(Number::from(0)),
+ max: None,
+ };
+ let screen_position_type = Type::Record {
+ name: "Screen Position".to_string(),
+ fields: vec![
+ Slot { name: "X".to_string(), r#type: nonnegative_int.clone() },
+ Slot { name: "Y".to_string(), r#type: nonnegative_int },
+ ],
+ };
+ vec![Slot { name: "mouse_position".to_string(), r#type: screen_position_type }]
+ }
+
+ fn outputs() -> Vec<Slot> {
+ let u24 = Type::NumberInRange {
+ min: Some(Number::from(0)),
+ max: Some(Number::from(1 << 24 - 1)),
+ };
+ vec![Slot { name: "screen_buffer".to_string(), r#type: Type::List { contents: Box::new(u24) }}]
+ }
+}