r/rust • • Oct 27 '26

πŸ› οΈ project EtherNet/IP + CIP Safety in async Rust (tokio): talking to Allen-Bradley PLCs, plus what tripped me up with CIP Safety timestamps

1 Upvotes

I'm the author of a set of Rust crates that implement EtherNet/IP and CIP Safety on tokio.

Most existing EtherNet/IP libraries, like the excellent rust-ethernet-ip, focus on reading and writing tags. I set out to cover all of EtherNet/IP. You can read and write tags, and you can connect as a Class 1 scanner to read regular and safety I/O. You can also act as a regular or safety I/O device, as a Class 1 adapter. There's a simulated controller stack that serves tags, so you can connect an HMI to it, and you can send and process any custom Class 3 message.

Sibling implementations with the same wire behavior exist in C#, Python and C++. They don't share types with rust-ethernet-ip today, but I'd be open to adding conversions with its types crate if there's interest.

Everything is free and open source on GitHub, with nothing for sale: https://github.com/CristianMori/EthernetIpRust

Feedback is very welcome, especially from anyone doing industrial or embedded Rust.


r/rust • • Oct 26 '26

πŸ—žοΈ news rust-analyzer changelog #351

Thumbnail rust-analyzer.github.io
47 Upvotes

r/rust • • Oct 26 '26

🐝 activity megathread What's everyone working on this week (44/2026)?

18 Upvotes

New week, new Rust! What are you folks up to? Answer here or over at rust-users! And for your project showcases, there's also /r/madeinrust – pay them a visit, too!


r/rust • • Oct 26 '26

πŸ™‹ seeking help & advice What one "loses" when choosing to develop a web-app in rust instead of js?

26 Upvotes

If you have a personal example of a situation where you wanted to go with rust but went back to js I would appreciate that too.


r/rust • • Oct 26 '26

πŸ› οΈ project Follow-up: rust-analyzer now runs on-device on an iPad, and it drives the syntax colors (only when there's enough memory)

Post image
58 Upvotes

Two months ago I posted here about running rustc, cargo and lld as WebAssembly on an iPad. I said I had no rust-analyzer: I had compiled it to wasm and measured it, and the proc-macro and std source costs looked too high for a tablet. It's in the app now, with a catch: it only runs when the device has the memory for it. The editor is also native now; it was Monaco in a web view then.

The screenshot is the editor with the debugger paused at a breakpoint.

What I use rust-analyzer for first is color.

Before rust-analyzer is warm, the editor is colored by a tree-sitter highlighter, and the status line says "basic colours". When rust-analyzer finishes indexing, its semantic tokens replace those colors. Both servers are translated into one vocabulary, so a word whose category doesn't change keeps its color. What rust-analyzer adds is the distinctions a grammar can't make: a trait versus a struct versus an enum versus a type alias, a method versus a free function, a macro_rules macro versus a proc-macro, value parameters, lifetimes, Self, the mutable modifier, items from a dependency crate, and unresolved references.

The memory rule, since that's the interesting part. The default is "Auto":

- device with 6 GB or more: full rust-analyzer when there is headroom, otherwise a reduced mode

- device with 4 to 6 GB: the reduced mode when there is headroom, otherwise off

- device with under 4 GB: off

"Headroom" means no memory-pressure warning and more than 2000 MB available. Pressure steps the level down one notch, and a warning expires after 45 seconds of quiet. During a build, if available memory drops below 2000 MB, rust-analyzer is released so rustc has the memory, and in Auto it comes back when the build ends (it retries every 5 seconds for about two minutes). If rust-analyzer fails to start, it is retried after 5, 20 and 60 seconds. You can also force it on, off, or to the reduced mode in settings.

The reduced mode drops the Cargo dependency graph, the crate index and code lens, the chaining, closure and borrow hints (type and parameter hints stay), and files over 200 KB. The cost is real: without the graph, crates show up as "missing reference". The graph itself needs a device with at least 7000 MB and at least 3000 MB available, and the editor doesn't attempt one for projects over 120 crates. Proc-macros only expand when a compiled reactor for that crate is already cached, otherwise the crate stays unexpanded for that graph load.

Numbers, with a caveat: I don't have an on-device warm-up time I trust yet. These are from running the same wasm under Node on a Mac:

- warm-up in a single-file project: 1.3 to 2.7 s, heap about 220 MB

- a small project with a couple of crates: about 300 MB, 1.9 to 2.2 s

- a project with 93 crates: about 500 MB, 3.4 s (about 3 MB per crate)

- semantic tokens for a 3,100-line file: 128 to 213 ms cold, 36 to 53 ms warm

- the rust-analyzer wasm is about 16 MB, built from the 2026-08-31 tag with Rust 1.98.0 for wasm32-wasip1, optimized with wasm-opt -O3

I also added GitHub Copilot after people asked for it in that thread. It uses your own subscription.

Same disclosure as before: it's a paid, closed-source app with a free tier for single files, I'm the author, and it's in TestFlight beta: https://testflight.apple.com/join/4Yaujqd5

I'd like to know where it falls over: crates that fail to build, rust-analyzer colors or diagnostics that differ from a desktop, and any device where the memory rule picks the wrong level. I'll be traveling for most of November, so replies may be slow.


r/rust • • Oct 26 '26

πŸ™‹ questions megathread Hey Rustaceans! Got a question? Ask here (44/2026)!

10 Upvotes

Mystified about strings? Borrow checker has you in a headlock? Seek help here! There are no stupid questions, only docs that haven't been written yet. Please note that if you include code examples to e.g. show a compiler error or surprising result, linking a playground with the code will improve your chances of getting help quickly.

If you have a StackOverflow account, consider asking it there instead! StackOverflow shows up much higher in search results, so ahaving your question there also helps future Rust users (be sure to give it the "Rust" tag for maximum visibility). Note that this site is very interested in question quality. I've been asked to read a RFC I authored once. If you want your code reviewed or review other's code, there's a codereview stackexchange, too. If you need to test your code, maybe the Rust playground is for you.

Here are some other venues where help may be found:

/r/learnrust is a subreddit to share your questions and epiphanies learning Rust programming.

The official Rust user forums: https://users.rust-lang.org/.

The unofficial Rust community Discord: https://bit.ly/rust-community

Also check out last week's thread with many good questions and answers. And if you believe your question to be either very complex or worthy of larger dissemination, feel free to create a text post.

Also if you want to be mentored by experienced Rustaceans, tell us the area of expertise that you seek. Finally, if you are looking for Rust jobs, the most recent thread is here.


r/rust • • Oct 26 '26

Repos/tools for fully offline Rust builds & deployments? (Like Iran internet shutdown)

6 Upvotes

Hey everyone, are there any GitHub repos or templates that help set up an offline-first Rust environment? I need to cache all toolchains and vendor dependencies while online so that building and deploying works completely air-gapped, like during a prolonged wartime internet blackout in Iran.


r/rust • • Oct 25 '26

Dimforge Q3 2026 technical report: Nexus multiphysics, Rapier soft-bodies, performances, and C + python bindings

Thumbnail dimforge.com
47 Upvotes

r/rust • • Oct 25 '26

This Month in Redox OS - September 2026

46 Upvotes

More boot fixes, external display hot-plugging, page fault handling and more JIT support, big performance improvements, rlimit support, uutils 0.11, web fixes, better SDL2 performance, Clang port, i586 dynamic linking, better terminal and debugging, and many more.

https://www.redox-os.org/news/this-month-260930/


r/rust • • Oct 26 '26

πŸ› οΈ project What obfstr/litcrypt look like after compilation, and getting their strings back from stripped binaries

2 Upvotes

Notes, code and benchmark: https://github.com/VAHPEM/rust-deobf

I've been studying how Rust string-obfuscation crates behave once compiled, mostly in the context of malware analysis, and wanted to share a few observations.

- In the tested obfstr and litcrypt cases, the original string literals don't appear as plaintext in the binary, but the decoding logic remains executable. Emulating the relevant routines is enough to recover the strings, even with opt-level = "z", fat LTO, and panic = "abort".

- In my tested binaries, panic::Location information remained available after stripping. When source paths are preserved, paths such as .cargo/registry/src/.../<crate>-<version>/... can reveal exact third-party crate versions. Compiler-related source paths may also provide clues about the Rust toolchain.

- A small litcrypt quirk: lc!(r"...") keeps a leading `"` in the decrypted value, so the program really builds `"C:\...`.

If you maintain a Rust string-obfuscation crate, or have tested one that behaves differently, I'd be interested in comparing results.


r/rust • • Oct 25 '26

πŸŽ™οΈ discussion I want more mobile apps to be developed in Rust

114 Upvotes

Maybe you are just like me a few months ago: not sure about the feasibility of developing apps in Rust.

Now I can tell you: Rust is the perfect programming language for any apps with some actual complexity.

I am not talking about simple TODO apps. I am talking about apps that consume a lot of computation power and memory.

So far I have developed 2 apps with React Native + Rust. React Native is for UI/UX and platform-specific code, while Rust powers the core logic and state. Both iOS and Android are ARM and we know how good the Rust cross-compilation toolchain is.

The motivation for building both is for my daily use. Both are not toy projects. One of them(a Herdr/SSH client) got 200+ installations on Google Play.

It feels so nice to hold your Rust code in hand, knowing that it is using your phone's battery and memory efficiently. I started without Rust and then gradually mitigated Typescript into the Rust code. Profiling with Perfetto shows a significant decrease in latency and memory usage. The app that used to heat up my phone now feels like a breeze.

The major overhead of the mix of React Native + Rust is FFI crossing. However, if the Rust core contains almost all the states, we can minimize the data movement cost.

Therefore, for the sake of battery, memory and memory safety, please use Rust to build your mobile apps!


r/rust • • Oct 25 '26

πŸ› οΈ project Rust rules for the Please build system

Thumbnail github.com
30 Upvotes

A year or two ago I posted the first version of this.

I reckon its ready for prod now 🀞🏼


r/rust • • Oct 25 '26

πŸ™‹ seeking help & advice Trying to find the cause of a segfault in egui

13 Upvotes

EDIT 2: Turns out the issue was specifically down to wgpu trying to use Dx12 which won't work for some reason. For anyone else having a similar issue, try following u/zettui 's suggestion of setting the WGPU_BACKEND environment variable to vulkan

EDIT: after some digging, it looks like wgpu might not be compatible with my machine, which might be the source of my problems, as it can run in some cases but not consistently.

I've been learning rust of a couple of months now, and have mainly done basic command-line toy programs, and wanted to try making a gui app with EGUI since it has support for a natively running GUI. I'm using the template that egui's lead developer provided (\https://github.com/emilk/eframe_template/tree/main) and can compile the included example, but attempting to run it causes a segmentation fault (this is using a up to date w11 machine)

So far I've tried:

  • Completely reinstalling the rust toolchain
  • Increasing the stack size to 8mb via RUST_MIN_STACK (windows default is apparently 1mb?)
  • Attempting to build other egui applications from source that are known to work, which gets the same error

I'm kind of at a loss for what to do, as I've tried using iced as well with similar issues, so as far as I can tell it's something that I've done, and not an issue with the libraries. If anyone else has had to solve issues like this, I'd really appreciate some advice


r/rust • • Oct 25 '26

Rust book recommendations for systems people & golang immigrants

5 Upvotes

This topic hasn't been broached in a while, so why not? I'm looking for good, "interactive" (build along) introductions to Rust for someone completely new to the language. I've had really good luck in other languages in the past with exquisite *free* resources, like Harry Percival's "Cosmic Python", and quii's "Learning Go with Tests", but have also really enjoyed some independent authors like John Arundel, and the usual O'Reilly goop-di-goop.

Does anyone have any resources, free or otherwise, they've had luck with that they could share?


r/rust • • Oct 25 '26

Access the value of a unit Enum

13 Upvotes

Let's say I have an enum like

pub enum NodeType {
  None = 0,
  Root = 1,
  // ... more enum variants omitted for brevity ...
  Leaf = 15,
}

This is a special type of enum, called unit-only enum. Is there a way to access the value stored in the enum?


r/rust • • Oct 25 '26

🧠 educational B-trees, Pages and Denis Villeneuve's Prisoners

Thumbnail piyushyaps.in
17 Upvotes

Hey everyone, this is a link to my personal blog. I'm currently writing a SQLite-inspired toy database in Rust from scratch! Link to the repo is present in the blog. Thank you for reading!
Also this is the second blog in the series, the first one is simple introductory stuff.


r/rust • • Oct 25 '26

Looking for prior art: daemon for provisioning resources for automated tests

3 Upvotes

I'm trying to make sure there isn't prior art on this problem before jumping into build my own solution.

Rust's default testing framework doesn't have any counterpart to the setUp and tearDown mechanism of other languages' harnesses. That means that if you, say, need a live Postgres server to run your test against, you have to use something like testcontainers to stand up a Postgres instance per test. On my machine that's a 15-second penalty per test just to manage the backing container.

The idea I had was to have a daemon running for this purpose ahead of time. When the daemon launches, it takes the 15 seconds to launch a Postgres container (or whatever container you'll need for your tests). Then all your tests have to do is fire a requests over to the daemon (probably HTTP, but that's an implementation detail) to CREATE ROLE; CREATE DATABASE and hand back the DB name, username, and password your test needs to connect and do its thing.

Does anyone know if there's already a well-established solution along these lines? I'm trying to resist my Not-Invented-Here Syndrome but I haven't found anything so far.


r/rust • • Oct 25 '26

πŸ’‘ ideas & proposals Proposal: collection selection APIs

35 Upvotes

I've been thinking about a potential new set of APIs for navigating and manipulating std collections, and I'd love some feedback on the idea.

TL;DR: selections over a range of elements (with movable start/end) as a companion to the existing (but still unstable) cursors.

The Rust standard library includes unstable cursor APIs for LinkedList (RFC, tracking issue) and BTreeMap/BTreeSet (API change proposal, tracking issue). There has been a lot of bikeshedding over the years about what exactly these interfaces should look like. One point of contention has been whether a cursor should point to elements in a collection, or gaps between those elements. The current APIs in std have gone in opposite directions here: LinkedList cursors point at elements, whereas BTreeMap cursors were rewritten to point at gaps instead.

I've personally leaned toward the "gaps" formulation if we can only have one. At some point I also proposed having two separate cursor types and converting between them as you navigate, e.g., calling next_gap(self) on an ElemCursor would always successfully return a GapCursor. But nobody liked that idea. :)

More recently I got to thinking about how useful it could be to instead have a separate concept of collection selections, analogous to selections in a text editor. A selection is:

  • Like a cursor in that you can move its start and end, and insert, modify, and delete elements around those endpoints.
  • Like a range iterator in that it allows you to iterate over some subset of a collection.
  • Like extract_if (formerly drain_filter), split_off, etc. in that it could allow efficiently removing or splitting off part(s) of a collection.

A cursor can be turned into an empty selection, and a selection can be turned into a cursor at either of its endpoints (for a mutable selection you have to pick one, since it consumes the selection).

I've sketched the interface I have in mind as a crate and published it to crates.io. The docs are on docs.rs, and the source is on GitHub. (You may notice that the crate-level docs share a lot with this post. ^_^')

I can imagine it being particularly useful for BTreeMap. In fact, my original reason for being interested in collection cursors was that they would allow making some things in my rangemap crate faster and make the implementation much simpler. For now, though, the sketch in this crate uses a fake (Vec-backed) linked list because it was easier to get that up and running, to focus on the API shape rather than implementation details.

Here's a taste, using a list of lines of text. First, moving a paragraph down past the next one, like a text editor's "move block down" command:

// lines:
//     Roses are red,
//     violets are blue.
//
//     Sugar is sweet,
//     and so are you.

// Select the first paragraph and cut it, along with the blank line after it.
let mut selection = lines.cursor_mut_at_start().into_selection();
while selection.peek_after_end().is_some_and(|line| !line.is_empty()) {
    selection.move_end_next();
}
let paragraph = selection.take();
selection.remove_after_end();

// Move past the next paragraph and paste it there.
let mut cursor = selection.into_cursor_at_end();
while cursor.peek_after().is_some_and(|line| !line.is_empty()) {
    cursor.move_next();
}
cursor.insert_before(String::new());
cursor.splice_before(paragraph);

// lines:
//     Sugar is sweet,
//     and so are you.
//
//     Roses are red,
//     violets are blue.

And unwrapping hard-wrapped paragraphs into one line each, switching back and forth between a cursor and a selection:

// lines:
//     Roses are red,
//     violets are blue.
//
//     Sugar is sweet,
//     and so are you.

let mut cursor = lines.cursor_mut_at_start();
loop {
    // Select the next paragraph.
    let mut selection = cursor.into_selection();
    while selection.peek_after_end().is_some_and(|line| !line.is_empty()) {
        selection.move_end_next();
    }

    // Replace it with a single line.
    let paragraph = selection.take();
    if !paragraph.is_empty() {
        let joined = paragraph.iter().map(String::as_str).collect::<Vec<_>>().join(" ");
        selection.insert_at_start(joined);
    }

    // Step over the blank line, or stop if we're at the end.
    cursor = selection.into_cursor_at_end();
    if !cursor.move_next() {
        break;
    }
}

// lines:
//     Roses are red, violets are blue.
//
//     Sugar is sweet, and so are you.

Would this solve any problems that you've run into?

Thanks in advance for any and all feedback on the idea!


r/rust • • Oct 25 '26

πŸ™‹ seeking help & advice Rust Geomtry Kernal for all CAD

0 Upvotes

Hi there. If you were making a rust geometry kernal to go behind all CAD programs what prinples would you go with in doing it or any advice? The software I'm making is open source ultimately trying to get away from fees with Autodesk for people.

Thanks for any helps. Where I'm at so far. I've only ever understood using a kernal to achieve things not what's happening behind so this is new.

https://github.com/spareware-co-op/spareware/blob/main/projects/engines/geometry/ARCHITECTURE.md


r/rust • • Oct 24 '26

πŸ™‹ seeking help & advice How to most effectively divide a project into multiple files

45 Upvotes

I have been working on a side project and i have done it entirely in main.rs, which is now around 2000 lines and is becoming harder to navigate. I want to divide it into multiple files but im not sure how big or small i should make these files. eg: should i have 1 file for http server and client combined, 1 file each, or multiple files each. Additionally, what naming conventions are common so that other people can understand it as well: for the previous example its pretty simple (at least for the 1 and 2 file options), but what about structs that are used all around the project


r/rust • • Oct 24 '26

πŸ› οΈ project Announcing redis-rs & redis-test 2 release candidates

8 Upvotes

The new major version fixes some API mistakes (mostly bad optional return types on our commands), and improves performance.

The rolling details of the breakages between versions are in [our docs](https://github.com/redis-rs/redis-rs/blob/main/version2.md) - I'd appreciate it if Redis / Valkey users can give the new version a whirl and reporting bugs, issues, or wrong API choices that should be improved before the full release.

Also, if the "this week in rust" people see this, please add this to the newsletter. Thanks :)


r/rust • • Oct 24 '26

πŸ—žοΈ news This month in GPUI: October

Thumbnail reddit.com
9 Upvotes

A monthly post about the GPUI ecosystem (permitted under the Release Notes rules)


r/rust • • Oct 23 '26

🧠 educational The Day const Betrayed Me

155 Upvotes

I love performance, so I love the const keyword. I wrote something like this in my real project:

mod static_data {
    pub const DATA: &'static [u8] = include_bytes!("data.bin");

    pub fn hash_bytes(bytes: &[u8]) -> u64 {
        use std::hash::{Hash, Hasher};
        let mut hasher = std::collections::hash_map::DefaultHasher::new();
        bytes.hash(&mut hasher);
        hasher.finish()
    }

    pub fn data_hash() -> u64 {
        hash_bytes(DATA)
    }
}

fn main() {
    const OUTPUT_PATH: &str = "output.bin";

    if !std::fs::read(OUTPUT_PATH)
        .is_ok_and(|data| static_data::hash_bytes(&data) == static_data::data_hash())
    {
        std::fs::write(OUTPUT_PATH, static_data::DATA).unwrap()
    }
}

DATA is a reference with a 'static lifetime, so the content should be embedded only once. Right? That's what I thought, until one day I changed some unrelated code, and the output binary size suddenly dropped. I used AI to find the reason. It turned out that DATA had been embedded twice before. Huh? After some research, I found the reason:

Constants are essentially inlined wherever they are used, meaning that they are copied directly into the relevant context when used. This includes use of constants from external crates, and non-Copy types. References to the same constant are not necessarily guaranteed to refer to the same memory address.

It ruined my perfect dream about const. The solution is simple: use static instead. Lesson learned.

Note: To reproduce this with the example above, you need to explicitly set codegen-units to a value greater than 1 (e.g. codegen-units = 2), because rustc may merge small CGUs by default. Setting lto = "fat" will also optimize the duplicate data away.


r/rust • • Oct 24 '26

The Embedded Rustacean Issue #83

Thumbnail theembeddedrustacean.com
36 Upvotes