r_rust🦀 – Telegram
r_rust🦀
62 subscribers
565 photos
65 videos
36.1K links
Posts top submissions from the rust subreddit every hour.

Powered by: @reddit2telegram
Chat: @r_channels
Download Telegram
Polynomial Regression crate (loess-rs) now available

Hey everyone. Just wanted to announce that a fully featured, robust, and solid Polynomial Regression (LOESS) crate has been released for Rust, available at loess-rs.

It is 3-25x faster than the original Fortran implementation by Cleveland (available in base R and Python scikit-misc package), and is as accurate (and even more robust) than the original implementation + offers a TON of new features on top of it: confidence/prediction intervals, cross-validation, boundary padding, different robustness weights, different kernels, ...

This is genuinely the most robust, the most flexible, and the fastest implementation of this frequently used algorithm in data science.

I believe Rust offers a perfect environment for implementing data science/bioinformatics algorithms, and I hope my crate contributes to the growing interest and usage by the community 🙌

https://redd.it/1q068hj
@r_rust
KHOJ : Rust based Local Search Engine

I have written a rust based local search engine Khoj
the numbers seem to be decent :

=== Indexing Benchmark ===
Indexed 859 files in 3.54s
Indexing Throughput: 242.98 files/sec
Effectively: 23.1 MB/sec

=== Search Benchmark ===
Average Search Latency: 1.68ms

=== Search Throughput Benchmark (5s) ===
Total Queries: 2600
Throughput: 518.58 QPS

What else should i change before publishing this as a package to apt/dnf?
And is it worth adding to resume?

https://redd.it/1q08drx
@r_rust
Announcement: aselect! - an alternative to tokio::select

https://github.com/avl/aselect

The tokio select! macro has two characteristics that can make it error-prone:

1. When one arm completes, all the other arms are canceled

2. When used in loops, if a handler runs async code, other arms are starved

aselect avoids these pitfalls by never canceling futures, and never starving them. The crate has not seen production use, so there could be bugs.

Feedback and suggestions welcome! Will something like this make async rust less error prone?


https://redd.it/1q0aig1
@r_rust
Create a Rust tool bfinder to find the top largest files.

I Built this rust tool which uses multi-threading to find the largest files fast. https://github.com/aja544/bfinder

Statistics:

Files scanned: 524013

Directories scanned: 124216

Errors: 0

Time elapsed: 4.380s



https://redd.it/1q0b1rz
@r_rust
I built sockudo-ws: A WebSocket library faster than uWebSockets (C++) with HTTP/2, HTTP/3, and io_uring support

Hey r/rust! I'm excited to share **sockudo-ws**, an ultra-low latency WebSocket library I've been working on for high-frequency trading and real-time systems.

## The Big Win

We're now **~17% faster** than the next fastest Rust WebSocket library, and we actually **match or beat uWebSockets** (the C++ industry standard) in throughput benchmarks:

| Library | Total Time (100k msgs) |
|---------|------------------------|
| **sockudo-ws** | **10.2ms** |
| fastwebsockets | 12.0ms |
| tokio-tungstenite | 34.8ms |

Against uWebSockets, we're achieving 1.02-1.03x their throughput across various workloads while providing a safe, ergonomic Rust API.

## What Makes It Fast?

- **SIMD acceleration** (AVX2/AVX-512/NEON) for frame masking and UTF-8 validation
- **Zero-copy parsing** - direct buffer access without intermediate allocations
- **Write batching (corking)** - minimizes syscalls via vectored I/O
- **Zero-copy API** via `RawMessage` that avoids String allocation for text messages

## Modern Protocol Support

This is where things get interesting. sockudo-ws supports not just HTTP/1.1, but:

- **HTTP/2 WebSocket** (RFC 8441) - multiplexed streams over a single connection
- **HTTP/3 WebSocket** (RFC 9220) - WebSocket over QUIC with 0-RTT and no head-of-line blocking
- **io_uring** - Linux kernel-level async I/O that can be combined with any protocol

The best part? **All transports use the same API**. Your WebSocket handler code works identically whether you're using HTTP/1.1, HTTP/2, HTTP/3, or io_uring underneath.

## Production Ready

- **Autobahn compliant** - passes all 517 test suite cases
- **permessage-deflate** compression
- **Split streams** for concurrent read/write
- **Tokio & Axum integration**

## Quick Example

```rust
use sockudo_ws::{Config, Message, WebSocketStream};
use futures_util::{SinkExt, StreamExt};

async fn handle(stream: TcpStream) {
let mut ws = WebSocketStream::server(stream, Config::default());

while let Some(msg) = ws.next().await {
match msg.unwrap() {
Message::Text(text) => ws.send(Message::Text(text)).await.unwrap(),
Message::Close(_) => break,
_ => {}
}
}
}
```

Same API works for HTTP/2 and HTTP/3!

## Where It's Used

sockudo-ws will power [Sockudo](https://github.com/RustNSparks/sockudo), a high-performance Pusher-compatible WebSocket server designed for HFT applications.

**Coming soon:** N-API bindings for Node.js

## Try It Out

```toml
[dependencies]
sockudo-ws = { git = "https://github.com/RustNSparks/sockudo-ws" }

# With all features
sockudo-ws = { git = "https://github.com/RustNSparks/sockudo-ws", features = ["full"] }
```

Full docs and examples: https://github.com/RustNSparks/sockudo-ws

---

I'd love to hear your feedback, especially from folks working on real-time systems or high-performance networking! Happy to answer questions about the implementation, benchmarks, or future plans.

**Edit:** Benchmarked on AMD Ryzen 9 7950X, 32GB RAM, Linux 6.18

https://redd.it/1q0fuf4
@r_rust
Standard Rust-only development environment?

A while ago I saw a video about an experiment where someone tried to use only Rust-based software for their daily work. That got me curious, so I decided to try something similar. I installed Redox OS in a virtual machine and started exploring what a “Rust-only” development environment might realistically look like.

I’m interested in learning which tools people would consider the most common or essential for such an environment—editors, build tools, debuggers, package management, etc.—ideally with links to documentation, manuals, or setup guides.

Do you think this is an interesting experiment worth trying out, or is it more of a “you’d have to be mad to try” kind of idea?

https://redd.it/1q0hd3d
@r_rust
[corroded update]: Rust--, now I removed the borrow checker from rust itself

You may have seen the [corroded](https://github.com/buyukakyuz/corroded) lib. I've been thinking, why bother with unsafe code while I can just remove the borrow checker from the compiler entirely?

Now possible at the language level:

* Move then use
* Multiple mutable references
* Mutable borrow then use original
* Use after move in loops
* Conflicting borrows

I've no idea where I'm going with this shit. But I think a lot of interesting stuff will pop up from this that I cannot think of at the moment.

Here is Rust-- for you, repo is [here](https://github.com/buyukakyuz/rustmm).

Happy new year. Enjoy.

https://redd.it/1q0kvn1
@r_rust
Introduction ffmpReg, a complete rewrite of ffmpeg in pure Rust

Hi Rustaceans, I’m 21 and I’ve been working on ffmpReg, a complete rewrite of ffmpeg in pure Rust.

The last 5 days I’ve been fully focused on expanding container and codec support. Right now, ffmpreg can convert WAV (pcm_s16le → pcm_s24le → pcm_f32le) and partially read MKV streams, showing container, codec, and timebase info. Full container support is coming soon.

If you find this interesting, giving the project a star would really help keep the momentum going 🥺.

https://preview.redd.it/g01f61ydklag1.png?width=2530&format=png&auto=webp&s=d751a1c9a4af7be9378060da36f4b1a3c7e5321c



https://redd.it/1q0maft
@r_rust
Is casting sockaddr to sockaddr_ll safe?

So I have a bit of a weird question. I'm using `getifaddrs` right now to iterate over available NICs, and I noticed something odd. For the `AF_PACKET` family the `sa_data` (i believe) is expected to be cast to `sockaddr_ll` (`sockaddr_pkt` is deprecated I think). When looking at the kernel source code it specified that the data is a *minimum* of 14 bytes but (seemingly) can be larger.


[https://elixir.bootlin.com/linux/v6.18.2/source/include/uapi/linux/if\_packet.h#L14](https://elixir.bootlin.com/linux/v6.18.2/source/include/uapi/linux/if_packet.h#L14)


Yet the definition of `sockaddr` in the libc crate doesn't seem to actually match the one in the Linux kernel, and so while I can cast the pointer I get to the `sockaddr` struct to `sockaddr_ll`, does this not cause undefined behavior? It seems to work and I get the right mac address but it "feels" wrong and I want to make sure I'm not invoking UB.

https://redd.it/1q0q9c5
@r_rust
Java dev learning rust… any projects need help?

Hey guys, experienced developer here just having fun learning Rust.

Currently building random things to get familiar with the ecosystem:

Built a front-end that replaces Lutris using Tauri

Working on a Flappy Bird clone with

macroquad

I think I’m ready to start contributing to something interesting and continue learning. Curious what this community recommends.

https://redd.it/1q0puu7
@r_rust
zero-mysql, zero-postgres: new DB libraries

https://preview.redd.it/qf1796fi1oag1.png?width=1200&format=png&auto=webp&s=d26438c02c01f8a4bf3421da9052c2de5a553736

[repo: zero-mysql](https://github.com/elbaro/zero-mysql)
repo: zero-postgres

zero-mysql and zero-postgres are developed for pyro-mysql and pyro-postgres (new Python DB libraries). pyro-mysql started with the mysql crate and went through various backend experiments including wtx and diesel, eventually leading to the own library. Since zero-mysql \+ pyro-mysql worked well, the same architecture is extended to zero-postgres \+ pyro-postgres.

[python mysql benchmark](https://github.com/elbaro/pyro-mysql/blob/main/BENCHMARK.md)
python postgres benchmark

# Handlers

These two libraries use Handler API to enable zero-cost customization without intermediate types. When a network packet containing row data arrives, Handler.row(packet: &[u8]) is called. Users can either drop this packet without even looking at it, collect it into a Vec using the provided parse functions, or directly convert it to a PyList or some third-party postgres plugin types. If you SELECT only fixed-length types (integer, float), you can even transmute &[u8] directly into your struct. (A derive macro for this will also be provided)

https://redd.it/1q0vr7p
@r_rust
How’s Rust doing for game development?

I was just thinking. Rust would be a great language to write a game engine in.

Pretty much all engines are in C++ at the moment, and memory is a pain to handle in these and they are very complex.

I reckon Rust could give a more modern feel but still have (possibly better, if using certain features) performance.


I’ve heard of Bevy. But I’m just imagining the benefits of stuff like Unity editor like a proper engine but with Rust.

https://redd.it/1q0wtnw
@r_rust
Trying to learn Rust without touching Claude Code

Hi everyone!

So, I graduated Software Development a few years ago. However, I am not sure I know what I am doing.

We mainly were taught PHP and web development, however, even in PHP, I would rather go to Claude Code right now than to figure it out myself.

It is a bad trait of mine and now that I want to start learning Rust I want to prevent this from happening again.

I have been reading the Rust book, and I understand most concepts and how to use them. What I am struggling with, is the fact that I do not understand clearly how all of this would be used to actually make an application.

I realize that in the years I have been using Claude Code, it caused me to he in this problem. Understanding concepts, but not how to use them.

What is the best I could do in this scenario? Just keep going with the Rust book even though I do not understand how to practically use the concepts that are being taught?

Like, I tried to make a calculator in the terminal, and I was just fully struggling with making it. I felt so stupid. How can I graduate and not be able to make this in Rust?

https://redd.it/1q13w8x
@r_rust