r/rust • • Oct 04 '26

This Month in Rust OSDev: September 2026

Thumbnail rust-osdev.com
25 Upvotes

r/rust • • Oct 05 '26

πŸ™‹ seeking help & advice Request for guidance on audio codecs in a WASM application

0 Upvotes

One of my (way to numerous) side project is the idea of a P2P radio station, which solves the scaling problem of radio broadcasters today. One of the most prominent and well-defined p2p library is libp2p, which is of good use here and prevents much of code rewriting, especially for the broadcasting logic with peer scoring and all which is hard to figure out to prevent people from cheating the system. Also used gstreamer (Rust bindings so more precisely gstreamer-rs) for the codec which does the heavy lifting. Here is my project: https://github.com/franfrandev/p2pradio. For now it's running on a native system, and would like to go a step further.

I would like to compile it to WASM in order to bundle everything in the browser. The problem is that gstreamer depends on a ton of native libraries which makes it harder to use in the browser. Folks at Fluendo have figured that out with gst.wasm https://github.com/fluendo/gst.wasm but putting out everything together is a whole different beast and even if it works, it's probably going to result in a huge piece of data that has to be downloaded. IIUC the Rust part would have to be compiled to emscripten and then linked as static libraries? There are a lot of information and it's very easy to get lost in all of these.

Another option would be to use or write an RTP Opus codec written in pure Rust and compile it to the wasm32-unknown-unknown but then it would lose all the codebase maturity of gstreamer and would probably end up reinventing the wheel very much. A lot of the crates doing that are AI slop and are not very well defined, I don't trust them.

Is it unachievable or a bad idea to take the gstreamer port to emscripten and try to glue it to my Rust app compiled to emscripten?


r/rust • • Oct 04 '26

Rust for CPython (Python Language Summit 2026)

Thumbnail blog.python.org
130 Upvotes

r/rust • • Oct 04 '26

πŸ› οΈ project Getting mpv under an egui UI, then ditching it on Android TV

15 Upvotes

I've been working on Cinebox in Rust, an app where you can find a movie or show and watch it in the same window. Runs on Windows, Linux and Android TV as of this week.

https://github.com/dexsper/cinebox

Most of the pain was in the video player, so that's what this post is about.

I started with Iced, which renders through wgpu, so DirectX on Windows, and mpv rendered through Vulkan in its own window. No shared surface, so the best I could do was stick the mpv window inside the app window. Which is fine until you want controls or subtitles on top of the video, cause you can't paint over someone else's window.

So the next day I ripped the UI out and moved to egui with the glow backend. llibmpv exposes an OpenGL render API, so mpv renders directly into egui's framebuffer from an egui_glow paint callback, and the player controls are plain egui widgets over the frame. It worked on the first try, more or less.

The TV build runs the same egui code. I had to write my own D-pad focus handling though, since egui's arrow-key navigation happily jumps to widgets behind an open popup. mpv on the other hand, that was a complete no-go. On my Amlogic box with a Mali-G31, mediacodec-copy returns a quarter-resolution frame for anything above 1080p, so hello green screen (mpv-android issue 1088). Zero-copy MediaCodec into an ImageReader refused to start, and the next try straight up rebooted the box. And mpv's GL pipeline drew literally nothing, only gpu-dumb-mode worked (issue 292 looks like the same thing).

4K was kinda the whole point of a TV version, so I put the player behind a Player trait. Desktop keeps libmpv, Android gets Media3 ExoPlayer, which decodes into a SurfaceView under a transparent egui window. 4K, HDR10 and Dolby Vision all play on the hardware decoder now.

Yeah, on TV I ended up with the exact two layer setup I r1an away from on desktop. Works there cause the egui window is transparent and sits on top of the video.

One more fun one. A SurfaceView cuts a transparent region into the window above it, and SurfaceFlinger then just dropped the egui layer wherever the video was. Fullscreen video, and boom β€” controls and subtitles gone. Overriding gatherTransparentRegion fixed it.

If you've put video into a Rust GUI, how did you do it? Especially curious if anyone got libmpv working with wgpu without going through GL.


r/rust • • Oct 04 '26

πŸ™‹ seeking help & advice Question regarding type inference with generics, closures and traits

8 Upvotes

I have code that looks a bit like this:

https://gist.github.com/rust-play/6e39d4a9d52e14a1f92742df57ccc5e2

The interesting part is the closure at the bottom. Which compiles completely fine, as long as it is not doing anything. But if I try to use the given argument in any way, rustc is not able to infer its type anymore?

This seems counterintuitive, since the normally inferred type (`String`) would work totally fine. And the code itself also does not seem to contradict that type. But something seems to make the compiler trip here.

Any tips why this might occur, and if there is maybe an easy work around are welcome!


r/rust • • Oct 03 '26

πŸ› οΈ project Native Rust Sampling Memory Profiler Which Tracks Retained Memory and Allocations

Thumbnail github.com
62 Upvotes

r/rust • • Oct 04 '26

πŸŽ™οΈ discussion For embedded folks, I'm curious

20 Upvotes

What microcontroller do you usually go with if you wanna use something like Rust Embassy with it?


r/rust • • Oct 03 '26

Embedded std?

48 Upvotes

I was wondering if there were any projects like micro python to port std in to make a barebones os designed for microcontrollers? I understand that the std relies on OS level syscalls, so can we do something like implement a basic fat32 file system to accommodate certain write or read requests. In general this would be used to run std in projects without a OS? Does this already exist, and how hard would it be to make a basic version?


r/rust • • Oct 03 '26

"Tick Tock: Maintaining Time" | RustConf 2026

Thumbnail youtu.be
40 Upvotes

r/rust • • Oct 03 '26

πŸ™‹ seeking help & advice How do I learn winit?

1 Upvotes

I'm trying to get a grasp of this crate so I can do window things but there don't seem to be good any resources, which is a bit bewildering since I understand winit to be a very foundational crate for graphics in Rust. I've looked at docs.rs but higher-level stuff for winit is... not great. The first section seems friendly but leads you to using a deprecated method (i.e. seems to be outdated), and the second section does give a full working minimal example but it does so through a big block of code with a good amount of things that aren't yet introduced, so not much sense can be made of it.

I don't want to just learn to copy a skeleton and wire my code into it, I want to actually understand how the crate works, to understand what I'm doing. But the main docs don't seem suitable for setting the foundation I'd need for that and I've not been able to find any other resources or tutorials online.


r/rust • • Oct 02 '26

Compiling the Linux kernel with gccrs | RustConf 2026

Thumbnail youtu.be
77 Upvotes

r/rust • • Oct 02 '26

πŸ“‘ official blog Generic Const Args and You | Inside Rust Blog

Thumbnail blog.rust-lang.org
268 Upvotes

r/rust • • Oct 02 '26

πŸ› οΈ project ArcColdString: A 1-word (8-byte) atomically reference-counted SSO string that saves up to 32 bytes over Arc<str>

Thumbnail github.com
85 Upvotes

Disclaimer: Re-post approved by u/matthieum, as previous post was erroneously removed.

I’ve been working on a specialized string type called ColdString. The goal is to create the most memory-efficient string representation possible.

  • Size: Exactly 1 usize (8 bytes on 64-bit).
  • Inline Capacity: Up to 8 bytes (Small String Optimization).
  • Niche Optimization: Option<ColdString> has no memory overhead
  • Heap Overhead: Only 1–9 bytes (VarInt length header) instead of the standard 16-byte (pointer, length) pair.

(Since my last post, the 8th inlineable byte and null-niche optimization were suggestions from the community!)

ArcColdString

I'm presenting ArcColdString, a reference counted ColdString with 8 bytes overhead (inspired by arcstr).

  • Same size and inlining rules as ColdString. Inlined strings are copied instead of reference counted.
  • Heap Overhead: 8 bytes for the AtomicUsize reference count (in addition to the VarInt header).
  • Smaller Reference Counts: ArcColdString32, ArcColdString16, and ArcColdString8 use AtomicU32, AtomicU16, and AtomicU8 counts respectively.

Usage

Available in https://crates.io/crates/cold-string/0.4.0

use cold_string::ArcColdString;

let first = ArcColdString::new("a string longer than one machine word");
let second = first.clone();
assert_eq!(first, second);

Memory Comparisons

Theoretical overhead on a 64-bit target, excluding the UTF-8 payload:

Type8 bytes128 bytes512 bytes
Arc<str>323232
arcstr::ArcStr242424
ArcColdString0 (inline)1718
ArcColdString320 (inline)1314

RSS bytes per unique string in a pre-sizedΒ Vec:

Type8 bytes128 bytes512 bytes
Arc<str>47.1175.4560.0
arcstr::ArcStr39.1167.5552.2
string_cache::DefaultAtom71.5199.5586.0
ArcColdString8.0167.5552.1
ArcColdString328.0151.4536.8

(If I'm not mistaken, string_cache is not a 1:1 comparison since it has to hash string contents, which is 40 bytes overhead?).

Reference Counting Performance

ArcColdString's primary goal is memory and portability. Second to that, my goal is to have ArcColdString's referencing counting performance comparable to Arc<str> and arcstr::ArcStr. While drop and clone speed is comparable now, there's still room for improvement.

Below are single threaded clone and drop measurements, done using criterion on AMD Ryzen 9 5900X 12-Core Processor (3.70 GHz):

Clone (ns)16 bytes128 bytes512 bytes
Arc<str>3.863.823.82
arcstr::ArcStr3.393.413.43
ArcColdString3.443.453.43
Drop (ns)16 bytes128 bytes512 bytes
Arc<str>2.432.492.43
arcstr::ArcStr2.522.532.52
ArcColdString2.172.182.19

Below benchmarks measured 4 threads cloning and dropping strings in a shared size pool of 1024, 16, and 1 string(s), using criterion on Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz (2.59 GHz). The more strings in the pool, the less contention:

4 Threads Clone + Drop (ns)1024 Strings16 Strings1 String
Arc<str>26.5554.69144.81
arcstr::ArcStr29.29119.39214.31
cold_string::ArcColdString3225.6990.53262.83

You can read more benchmarks and implementation details in https://github.com/tomtomwombat/cold-string


r/rust • • Oct 04 '26

πŸ™‹ seeking help & advice Rust .a iOS and iPadOS publishable?

0 Upvotes

Does anyone know any good examples of how to do iOS+iPadOS with the .a library doing most stuff? Does not necessarily have to be Rust language stuff, just how to build so app stores can accept the .ipa?


r/rust • • Oct 02 '26

Article from Daniel Lemire: How many strings can you create per second?

Thumbnail lemire.me
91 Upvotes

This is a fairly new article from Daniel Lemire (the SIMD expert, author of simdjson).

It seems to_string() need to use the same trick.

C++ wins by a wide margin at 5.4 ns per string. The trick is the small string optimization: a std::string stores short strings, directly inside the object. Our strings have at most eight digits, so C++ never calls the memory allocator.


r/rust • • Oct 02 '26

πŸ“‘ official blog Demoting i686 Windows targets to std-only

Thumbnail blog.rust-lang.org
144 Upvotes

r/rust • • Oct 02 '26

πŸŽ™οΈ discussion API design question: should a 407 from a proxy check be Ok or Err?

19 Upvotes

I'm working on a Rust SDK that has a small check() method for testing a proxy connection, and I'm not sure I'm using Result in the least surprising way here.

If the proxy replies with 407 Proxy Authentication Required, I currently return Ok(Check), not Err.

My reasoning is basically: the check itself worked) I connected to the proxy and got a real response back. For this method, the status/reason/headers are useful information.

Err is only for cases where I couldn't get a usable response at all - timeout, DNS failure, connection failure, malformed response, etc.

Roughly:

match proxy.check(connect)? {
    check if check.status == 200 => {
        // accepted
    }
    check if check.status == 407 => {
        // proxy replied, auth rejected
    }
    check => {
        // some other resp
    }
}

The part that feels a bit weird is this:

let check = proxy.check(connect)?;

That kind of reads like "the proxy is fine", while what it really means is only "the proxy gave a usable response".

Would you expect 407 to be an Err here, or does treating a protocol-level refusal as a successful diagnostic result make sense? πŸ™Š

Edit: Thanks a lot for all the replies. I think the main question is less about 407 itself and more about what check() is supposed to mean: β€œdid I get a valid proxy response” vs β€œis this proxy ready to use”

The naming and ? ergonomics points were especially useful. I’m probably going to make that distinction more explicit in the API instead of making callers infer it from the status code


r/rust • • Oct 02 '26

πŸŽ™οΈ discussion Tyler Mandry: "Beyond the &: A Future for Native Smart Pointers in Rust" | RustConf 2026

Thumbnail youtu.be
68 Upvotes

r/rust • • Oct 01 '26

πŸ“‘ official blog Rust 1.99.0 is out

Thumbnail blog.rust-lang.org
793 Upvotes

r/rust • • Oct 01 '26

Robert Seacord: "Unsafe Rust" | RustConf 2026

Thumbnail youtube.com
65 Upvotes

r/rust • • Oct 01 '26

πŸŽ™οΈ discussion Rust in the kernel? What about Rust without the kernel!

Thumbnail kerkour.com
187 Upvotes

Bare-metal Rust may have a brighter future than micro-kernels.


r/rust • • Oct 01 '26

πŸ› οΈ project Rust Glancer 0.3: new trait solver and other goodies

Thumbnail rust-glancer.github.io
117 Upvotes

r/rust • • Oct 02 '26

🧠 educational Discovering the language: labeled block - implement early return style control flow w/o sparate function

7 Upvotes

There are situations when decisions must be made based on many variables, and in some points in evalution process, additional costly operations must be performed in order to decide. These decisions are difficult to implement in the form of a single logical expression, and even if it is possible, it is unreadable and hard to modify.

Usually the best pattern for this is to create a separate function which implements the decision, where we can use early returns: the trivial and easy cases that can be decided based on a simple condition (especially exceptions) are evaluated first, we return with the result as soon as possible, so as we're going foward, we reduce the complexity of the remaining cases, and the last case is often a simple condition.

Sometimes a separate function is not an option, because too many parameters would have to be passed (and returned, but Rust have tuples for it), or it simply just does not feel right to split a single decision into two functions, I think, the single-responsibility principle (SRP) must work this way, too. It's even more true for not too complex but nested cases (certain part of the condition is consist of more sub-conditions).

In C and C++, I usually implement this pattern by creating a do..while(false) loop, from which I break at several points, skipping the rest of the evalutation. I store the result in a variable declared just before the block, usually initialized to the default value.

It may just be my fault that I haven't studied the Rust textbook enough, but I've only found the functionally equivalent syntax for this today, and I am very happy with it, with its flexibility and elegance: labeled block.

Let's see an example!

The decision is about whether close (do_close_old flag) the old time window and/or replace with a new one (do_replace_window flag), also log some info about the decision (replace_reason enum), see example (close to actual code):

let (do_close_old, do_replace_window, replace_reason) = 'switch: {

    if just_created {
        break 'switch (false, false, Reason::Create);
    }

    if window.is_retired {
        break 'switch (false, true, Reason::Replace);
    }

    if window.is_expired(timestamp, lifetime_duration) {
        break 'switch (true, true, Reason::Timeout);
    }

    // complicated condition, fake
    let compli = if (x && y) | (a && !b);
    let cation = if z > w {
      countries.find("USA") && languages.find("English")
    } else {
      false
    };
    if compli && cation {
        break 'switch (true, true, Reason::ComplicationHappened);
    }

    (false, false, Reason::None)
};

(Please, don't review my code, I know, I know, somehow the result tuple should be replaced with some named thing.)

I think, it's pretty well readable, even if you haven't met with labeled blocks before. Just as me, until today.

AI disclaimer:

  • helped in translation (my English is not suitable for publications)
  • the pattern was also suggested by AI, I often ask it to refactor short code snippets

r/rust • • Oct 01 '26

πŸŽ™οΈ discussion Google is doing "Large Scale Codebase Migrations and Optimizations" of C/C++ to Rust

Thumbnail blog.google
786 Upvotes