This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [package] | |
| name = "app" | |
| version = "0.1.0" | |
| edition = "2021" | |
| [lib] | |
| crate-type = ["cdylib", "rlib"] | |
| path = "src/lib.rs" | |
| name = "app_core" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::collections::VecDeque; | |
| #[derive(Debug, Clone)] | |
| struct Event(u32); | |
| struct Context { | |
| queued_events: VecDeque<Event>, | |
| } | |
| impl Context { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::sync::atomic::{AtomicBool, Ordering}; | |
| use std::marker::PhantomData; | |
| // Simulate hardware-specific types | |
| mod hal { | |
| pub mod peripherals { | |
| pub struct TIMER0; | |
| pub struct UART0; | |
| pub struct GPIO; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // thiserror = "1.0.63" | |
| use std::{ | |
| io::{BufRead, BufReader, Write}, | |
| process::{Child, Command, Stdio}, | |
| sync::{ | |
| mpsc::{self, Sender}, | |
| Arc, Mutex, | |
| }, | |
| thread, | |
| time::Duration, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| set windows-shell := ["powershell.exe"] | |
| export RUST_LOG := "info" | |
| export RUST_BACKTRACE := "1" | |
| @just: | |
| just --list | |
| build: | |
| cargo build -r |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // This is a macro that can generate the egui enum dropdown pattern for a c-style Rust enum | |
| // meaning it contains only fieldless, unit variants | |
| #[macro_export] | |
| macro_rules! generate_enum { | |
| ( | |
| $name:ident { | |
| $($variant:ident),* $(,)? | |
| } | |
| ) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // [dependencies] | |
| // async-std = { version = "1.12.0", features = ["attributes"] } | |
| // futures = "0.3.30" | |
| use async_std::{ | |
| future::timeout, | |
| sync::{Arc, Mutex}, | |
| }; | |
| use futures::{ | |
| channel::mpsc::{unbounded, UnboundedReceiver, UnboundedSender}, | |
| futures::stream::StreamExt, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // petgraph v0.6.5 | |
| use petgraph::graph::{NodeIndex, DiGraph}; | |
| fn number_children(graph: &DiGraph<(), ()>, parent: NodeIndex, depth: usize) -> Vec<(NodeIndex, usize, usize)> { | |
| let mut tree = Vec::new(); | |
| let mut index = 0; | |
| // Start numbering the children from index 0 | |
| for child in graph.neighbors(parent) { | |
| tree.push((child, index, depth)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // petgraph v0.6.5 | |
| use petgraph::graph::DiGraph; | |
| use petgraph::visit::{EdgeRef, Topo}; | |
| fn main() { | |
| // Create a new directed graph | |
| let mut graph = DiGraph::new(); | |
| // Add nodes and edges (similar to previous examples) | |
| let a1 = graph.add_node("A1"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #[derive(Debug, Clone, Serialize, Deserialize)] | |
| pub struct CustomGraph { | |
| pub graph: petgraph::Graph<MakelineNode, ()>, | |
| } | |
| impl PartialEq for CustomGraph { | |
| fn eq(&self, other: &Self) -> bool { | |
| graph_eq(&self.graph, &other.graph) | |
| } |