r/rust

I wrote an S3 client in Rust that outruns aws-cli. Please tear it apart.
▲ 2 r/rust+2 crossposts

I wrote an S3 client in Rust that outruns aws-cli. Please tear it apart.

Hey all, a few months ago I got curious and wrote an S3 client in Rust. To my own surprise it ended up faster than mc, s5cmd and aws-cli at uploading to the self-hosted backends I tested (MinIO, SeaweedFS and Garage), and about level with mc on downloads. I have written a technical blog here, I am still a newbie when it comes to this stuff so bear with me: https://jaeaeich.com/writing/s3z. Please read or listen to it, the benchmarks were only run locally, so I'm sure there's plenty to poke at, and I'd really value hearing what I got wrong or could have done better.

u/JaeAeich — 5 days ago
▲ 309 r/rust+1 crossposts

Made a desk status monitor

Hey, just wanted to share the small rust embedded project I made and that I use daily to monitor the status of a couple of services.

It also displays notifications from claude code, codex or any application capable of sending an http request.

It was my first time using rust with no-std, it's actually quite fun.

https://github.com/fkhadra/esp-notify

u/Gugu108 — 10 days ago
▲ 12 r/rust

typex: Runtime reflection for Rust

I've published typex, a small Rust library for runtime reflection. I built it for a template language that needed to access Rust structs without serde and wanted something lighter than bevy_reflect.

It can inspect or mutate struct fields by name without knowing their concrete type. You can batch changes and undo them afterwards.

Common Rust types and collections are supported out of the box. For your own structs and enums, derive Meta for reflection and MetaMut for mutation. It works with no_std + alloc, has no runtime dependencies and uses no unsafe code.

Here's an example:

use typex::{Meta, Object};

#[derive(Meta)]
struct Counter {
  count: u8,
}

let object = Object::new(Counter { count: 3 });
assert_eq!(object.field_names(), &["count"]);

let count = object.field("count").unwrap();

println!("{}", count.type_name()); // u8
assert_eq!(count.to_ref::<u8>(), Some(&3));

To apply a batch of updates, then undo it:

use typex::{MutationBatch, PatchOperation, PathSegment};

let mut values = vec![1_u8];
let batch = MutationBatch::from([
  PatchOperation::set([PathSegment::Item(0)], 2_u8),
  PatchOperation::push_item([], 3_u8),
]);

let rollback = batch.commit(&mut values).unwrap(); // [2, 3]
rollback.undo(&mut values).unwrap();               // [1]
reddit.com
u/tindzk — 10 days ago
▲ 10 r/rust

My WASM Python Implementation Beat CPython (Without a JIT)

Okay. After seven months, I'm back.

Seven months ago I started writing a Python interpreter from scratch in Rust, compiled to wasm (less than 200kb of bandwith). Edge Python is a sandboxed subset of Python that runs in the browser and the terminal, and code can't touch files or the network unless you allow it.

It started as a lexer and a simple stack VM, and over about 1,600 commits it grew a CLI, a package registry, snapshots, actors and a browser playground. It's just me building it.

Last week it was still 3x slower than CPython. I rewrote the VM this weekend on top of the SSA form I already had, and now the wasm build beats native CPython on loops.

Edge (wasm) CPython (native)
Integer loop 154 ms 232 ms
Float math 231 ms 307 ms
Dicts 372 ms 62 ms
Strings 196 ms 35 ms

The trick was a register VM, and Rust made it fit in wasm with NaN-boxed values and no runtime. It still loses on dicts and strings, so that's next.

Try to break my numbers :)

Website: https://edgepython.com/

GitHub: https://github.com/dylan-sutton-chavez/edge-python

u/Healthy_Ship4930 — 10 days ago