Examples
The repository has an example program for every feature of Raio, in both languages. Most Python examples have a Rust example of the same name that does the same thing.
Python
Run one with python python/examples/<name>.py from the repository.
| Example | Shows |
|---|---|
hello.py | Two nodes and one connection. |
timer.py | A timer made of raio.wait in a loop. |
ticker.py | A node with settings, used by other examples. |
reaction.py | One reaction triggered by two ports. |
select_first.py | A task that waits for the first of two ports. |
sync.py | Pairing the values of two ports that share a timestamp. |
join.py | Two tasks of one node at different rates. |
same_timestamp.py | A node that receives values and also sends one of its own. |
action.py | Keyboard input from a thread, through an action. |
ping_pong.py | A loop of connections with a delay. |
physical.py | A loop closed by a physical connection. |
serializer.py | A connection with its own serializer. |
shutdown.py | Shutting down every node at one timestamp. |
interrupt.py | Shutdown methods that run on Ctrl-C. |
scale.py | The Python declaration of a Rust node. |
mixed.py | A Rust node between two Python nodes. |
Rust
Run one with cargo run --example <name>.
| Example | Shows |
|---|---|
hello.rs | Two nodes and one connection. |
timer.rs | A timer made of node.wait in a loop. |
reaction.rs | One reaction triggered by two ports. |
reaction_order.rs | Reactions run in the order in which they are declared. |
select.rs | A task that waits for the first of two ports. |
sync.rs | Pairing the values of two ports that share a timestamp. |
join.rs | Two tasks of one node at different rates. |
same_timestamp.rs | A node that receives values and also sends one of its own. |
fanout.rs | One output that feeds two inputs, one of them with a delay. |
action.rs | Input from a thread, through an action. |
foreign.rs | Awaiting a future of another runtime. |
ping_pong.rs | A loop of connections with a delay. |
physical.rs | A loop closed by a physical connection. |
serializer.rs | A connection with its own serializer. |
shutdown.rs | Shutting down every node at one timestamp. |
interrupt.rs | Shutdown functions that run on Ctrl-C. |
failure.rs | A node that fails, and the app shutting down around it. |
silent.rs | A node that blocks its thread and misses its heartbeats. |
diagram.rs | Drawing an app to an SVG file. |
node.rs | A program that runs a single node of an app. |
scale.rs | A node for a mixed Rust and Python app. |