Skip to main content

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.

ExampleShows
hello.pyTwo nodes and one connection.
timer.pyA timer made of raio.wait in a loop.
ticker.pyA node with settings, used by other examples.
reaction.pyOne reaction triggered by two ports.
select_first.pyA task that waits for the first of two ports.
sync.pyPairing the values of two ports that share a timestamp.
join.pyTwo tasks of one node at different rates.
same_timestamp.pyA node that receives values and also sends one of its own.
action.pyKeyboard input from a thread, through an action.
ping_pong.pyA loop of connections with a delay.
physical.pyA loop closed by a physical connection.
serializer.pyA connection with its own serializer.
shutdown.pyShutting down every node at one timestamp.
interrupt.pyShutdown methods that run on Ctrl-C.
scale.pyThe Python declaration of a Rust node.
mixed.pyA Rust node between two Python nodes.

Rust​

Run one with cargo run --example <name>.

ExampleShows
hello.rsTwo nodes and one connection.
timer.rsA timer made of node.wait in a loop.
reaction.rsOne reaction triggered by two ports.
reaction_order.rsReactions run in the order in which they are declared.
select.rsA task that waits for the first of two ports.
sync.rsPairing the values of two ports that share a timestamp.
join.rsTwo tasks of one node at different rates.
same_timestamp.rsA node that receives values and also sends one of its own.
fanout.rsOne output that feeds two inputs, one of them with a delay.
action.rsInput from a thread, through an action.
foreign.rsAwaiting a future of another runtime.
ping_pong.rsA loop of connections with a delay.
physical.rsA loop closed by a physical connection.
serializer.rsA connection with its own serializer.
shutdown.rsShutting down every node at one timestamp.
interrupt.rsShutdown functions that run on Ctrl-C.
failure.rsA node that fails, and the app shutting down around it.
silent.rsA node that blocks its thread and misses its heartbeats.
diagram.rsDrawing an app to an SVG file.
node.rsA program that runs a single node of an app.
scale.rsA node for a mixed Rust and Python app.