Posts about Rust
![Subreddit Icon](http://web.archive.org./web/20230903015324im_/https://styles.redditmedia.com/t5_2s7lj/styles/communityIcon_pjg3ktzyju771.png)
![Subreddit Icon](http://web.archive.org./web/20230903015324im_/https://styles.redditmedia.com/t5_28h1wz/styles/communityIcon_7w428grla6w61.jpg?format=pjpg&s=26970a1c352aad1171cae5d304abff63ba31f806)
![Subreddit Icon](http://web.archive.org./web/20230903015324im_/https://styles.redditmedia.com/t5_32iyy/styles/communityIcon_aswtsgu843b91.png)
![Subreddit Icon](http://web.archive.org./web/20230903015324im_/https://styles.redditmedia.com/t5_4ao35o/styles/communityIcon_vxwguyha21ya1.png)
![Subreddit Icon](http://web.archive.org./web/20230903015324im_/https://styles.redditmedia.com/t5_3amtr/styles/communityIcon_qqdec9gji3l11.png)
![Subreddit Icon](http://web.archive.org./web/20230903015324im_/https://styles.redditmedia.com/t5_2fwo/styles/communityIcon_1bqa1ibfp8q11.png)
![Subreddit Icon](http://web.archive.org./web/20230903015324im_/https://b.thumbs.redditmedia.com/nzkKm4oX0VMp2dkeyrV4irR15-cj7WTjh3pnvksDfuE.png)
![Subreddit Icon](http://web.archive.org./web/20230903015324im_/https://styles.redditmedia.com/t5_3hq52e/styles/communityIcon_4dxhhwgmju861.jpg?format=pjpg&s=2da207274e155cc745c7f314d0cc97a684bcd853)
![Subreddit Icon](http://web.archive.org./web/20230903015324im_/https://styles.redditmedia.com/t5_2tteh/styles/communityIcon_whaqu6hvdx831.png)
![Subreddit Icon](http://web.archive.org./web/20230903015324im_/https://styles.redditmedia.com/t5_2s8x6/styles/communityIcon_ftfh5okvyxj01.png)
![Subreddit Icon](http://web.archive.org./web/20230903015324im_/https://styles.redditmedia.com/t5_2smzg/styles/communityIcon_jux4a4tjuhu31.png)
![Subreddit Icon](http://web.archive.org./web/20230903015324im_/https://styles.redditmedia.com/t5_2s1dk/styles/communityIcon_9blmfwwedml91.png)
![Subreddit Icon](http://web.archive.org./web/20230903015324im_/https://styles.redditmedia.com/t5_2rr81/styles/communityIcon_pkdxzm7p2n951.jpg?format=pjpg&s=1567c61df184303ba3aaabbcef95d80f67de5f40)
![Subreddit Icon](http://web.archive.org./web/20230903015324im_/https://styles.redditmedia.com/t5_28fhh5/styles/communityIcon_ngrmugr3wp471.png)
![Subreddit Icon](http://web.archive.org./web/20230903015324im_/https://styles.redditmedia.com/t5_2qh03/styles/communityIcon_1isvxgkk7hw51.png)
![Subreddit Icon](http://web.archive.org./web/20230903015324im_/https://b.thumbs.redditmedia.com/doDU32f_gKJX0khzhw9Z9UA2B9h-dSHryoNjrofhIYg.png)
![Subreddit Icon](http://web.archive.org./web/20230903015324im_/https://styles.redditmedia.com/t5_2scss/styles/communityIcon_05288t6b3do21.jpg?format=pjpg&s=432a32593006c0b240c2ecffa5a8d00edfd88fdd)
![Subreddit Icon](http://web.archive.org./web/20230903015324im_/https://styles.redditmedia.com/t5_2se24/styles/communityIcon_ju7yqh1bxs531.jpg?format=pjpg&s=1c14daf76051c4e3658be4e4195a43d677cb0fd0)
![Subreddit Icon](http://web.archive.org./web/20230903015324im_/https://styles.redditmedia.com/t5_2tex6/styles/communityIcon_70ds7qqgfr8b1.png)
![Subreddit Icon](http://web.archive.org./web/20230903015324im_/https://styles.redditmedia.com/t5_4glvl1/styles/communityIcon_32cxwntfnk071.jpg?format=pjpg&s=6df470f3aa59a4339e242247e47428e3ee1c88be)
![Subreddit Icon](http://web.archive.org./web/20230903015324im_/https://b.thumbs.redditmedia.com/XAEM69hguRUMp0qbFGYIuKPKv7KbOciHzM63GTGRnCQ.png)
![Subreddit Icon](http://web.archive.org./web/20230903015324im_/https://styles.redditmedia.com/t5_3oeyf/styles/communityIcon_r1fnjc5x5lba1.png)
A few months ago, NSA recommended Rust as an alternative to C and C++ and now CISA (I had to look it up, CISA is the Cybersecurity and Infrastructure Security Agency) is talking about how memory safe languages like Rust can remove a whole class of security vulnerabilities: CISA Director Jen Easterly Lecture and Fireside Chat.
I work on Rust in Android and I find it really encouraging to see the language being highlighted again and again as a safe alternative to C and C++.
Edit 1
Already open-sourced. But please wait for maybe one day, before I clean up everything and publish it! https://github.com/fzyzcjy/flutter_rust_bridge
Original
I have made a bindgen to allow Dart/Flutter to call Rust via FFI. It is memory safe, and you do not need to care about anything like allocate/free an object.
Question: Anyone interested in it? If many people are interested, I can polish it can make it open-source. (Since you know, making it open-source will require some time and efforts.)
Memory-safe: never need to think about alloc/free.
Zero-copy (almost): Big objects can be passed from Rust to Dart without any copy.
Rich type support: Not only primitives like int/double, but also Uint8List(Vec<u8>), List<T>(Vec<T>), any custom structs. You can even use recursive structs.
Async programming: Your Rust code can run for a long time, and it will not block the main isolate (i.e. not block UI). You can call functions directly in main isolate of Dart, so no need for switching between isolates.
Easy to use: All you need to do is write down your Rust code. The bindgen will do everything and expose an API in the Dart/Flutter style.
Write the following Rust code (that is all you need to do!):
pub struct TreeNode {
pub value: i32, # of course, also support also support other types
pub children: Vec<MyTreeNode>,
}
pub fn hello_world(s: MyTreeNode, b: SomeOtherStruct) -> Result<Something> {
Ok(...)
}
It will automatically generate everything, and you only need to call a generated Dart/Flutter API which looks like:
class ExampleApi {
Future<Something> helloWorld({required MyTreeNode a, required SomeOtherStruct b}) async { ... auto generated implementation ... }
}
P.S. There already exists a low-level one (in the C style), but all memory alloc/free should be done manually, so it is quite unsafe. That is why I do this high-level bindgen.
Edit 2: You choose the name of this lib!
What name do you think is the best? If many people vote on your suggested name, I will use it. (Fallback name: flutter_rust_bridge
).
Oh I see editing a post will not make any notifications. So this edit is almost useless...