Crates.io | roto |
lib.rs | roto |
version | 0.7.0 |
created_at | 2022-08-19 08:48:42.633718+00 |
updated_at | 2025-08-25 08:23:29.9689+00 |
description | strongly-typed, compiled language for Rotonda |
homepage | https://www.nlnetlabs.nl/projects/routing/rotonda/ |
repository | https://github.com/NLnetLabs/roto/ |
max_upload_size | |
id | 648616 |
size | 1,101,613 |
Roto is an embedded scripting language for Rust applications that is fast, safe and easy to use.
The language is primarily used by Rotonda, the composable, programmable routing BGP engine. It is made to integrate especially well with Rotonda, so that writing filters is as simple as possible. In addition, Roto can be easily embedded into any Rust application for general purpose scripting.
Read more about it in the documentation.
# A function that returns true if an IP address is equal to 0.0.0.0
fn is_zero(x: IpAddr) -> bool {
x == 0.0.0.0
}
# A filtermap that only accepts IP addresses of 0.0.0.0
filtermap main(x: IpAddr) {
if is_zero(x) {
accept
} else {
reject
}
}
More examples can be found in the examples
folder in this repository. They
can be run with
cargo run --example <example name>
These limitations are fundamental to the design of Roto. They stem from the fact that Roto is a scripting language and that Rust's reflection system is limited.
Clone
or Copy
. Rust types that
don't implement these traits should be wrapped in an Rc
or Arc
. The reason
for this limitation is that Roto does not have references and freely clones
values.Vec<u32>
is possible, but Vec<T>
is not. We plan to support registering
generic via some form of type erasure.'static
lifetime.Some limitations are only present because we haven't come around to implementing them yet. Most limitations can be found in the issue tracker, but we've summarized some important missing features here.
enum
types.
(#188)Roto fundamentally relies on unsafe code, after all, we are generating machine code at runtime. However, we treat every unsoundness stemming from use of Roto with safe Rust as a bug of high priority. Please report any issues you find to the GitHub repository.
We run our extensive test suite under Valgrind in CI to ensure that at least most common use cases are correctly implemented.
If you allow users to submit untrusted Roto scripts to your application, you need to be aware that malicious (or erroneous) Roto scripts can do the following:
while
loop, orTherefore, we make the following recommendations:
Finally, Roto scripts have access to all functions you provide and are therefore as contained as you want them to be. Be careful not to expose information or functionality that compromises the security of your application.
If you have comments, proposed changes, or would like to contribute, please open an issue in the GitHub repository. In particular, if you would like to use the crate but it is missing functionality for your use case, we would love to hear from you!
Roto is distributed under the terms of the BSD-3-clause license. See LICENSE for details.