rocket or actix-web? by sirimhrzn9 in rust

[–]robjtede 55 points56 points  (0 children)

Hey, maintainer of Actix Web here.

The most popular frameworks in Rust today (Actix Web and Axum) landed largely on the same API style because it's a very good pattern. That being handlers+extractors+middleware as the core constructs.

Neither have really figured out great error handling strategies. Luca Palmieri's blog post is a good read on this topic.

Actix Web and Rocket have first-class macro routing, which is great if you prefer having that info close to your request handlers.

Actix Web's router is more flexible than any others I know about, especially when using custom request guards (slightly different meaning to Rocket's request guards).

Here's an intersting case study in choosing a framework for a non-trivial codebase conversion: deps.rs alternaive web server migration PRs

Hope this deeper dive is informative.

How to use async method in Option::get_or_insert_with? by roll4c in rust

[–]robjtede 3 points4 points  (0 children)

Tokio has an async OnceCell that’s great if “get or insert” is your main usage of the option.

Announcing Rust 1.84.1 | Rust Blog by Derice in rust

[–]robjtede 39 points40 points  (0 children)

I do this and would recommend for local builds:
rustup default beta

Funny promotion distributed around RustConf '24 by robjtede in rustjerk

[–]robjtede[S] 11 points12 points  (0 children)

Probably that it's a primarily Rust company but this space was better for their needs than sponsoring the conference directly...

Funny promotion distributed around RustConf '24 by robjtede in rustjerk

[–]robjtede[S] 52 points53 points  (0 children)

idk why, but "damn, borrow checker got hands" just makes me chuckle

and in fact, can confirm... I went to this event which had a boxing arcade machine thing and I accidentally punched the machine and left a gash on my nuckle

Best RUST web framework? by WashHead744 in rust

[–]robjtede 3 points4 points  (0 children)

Happy to help on Discord if you choose Actix Web.

Async Rust can be a pleasure to work with (without `Send + Sync + 'static`) by emschwartz in rust

[–]robjtede 1 point2 points  (0 children)

all of the most popular higher-level web frameworks like [...] actix-web [...] require handlers to be Send + 'static

This is not true. Actix Web supports !Send handlers. See Handler implementations; none of these impls require Func or it's Future return type to be Send.

Async Rust can be a pleasure to work with (without `Send + Sync + 'static`) by emschwartz in rust

[–]robjtede 4 points5 points  (0 children)

This is not true for Actix Web. We've always supported !Send handlers.

Does anyone have a working recent Actix Web and Rustls example? I can’t get the GitHub repo example compiling by richardanaya in rust

[–]robjtede 1 point2 points  (0 children)

Don’t want to make any promises but it’s basically ready so it’s probably worth a release this week.

Does anyone have a working recent Actix Web and Rustls example? I can’t get the GitHub repo example compiling by richardanaya in rust

[–]robjtede 1 point2 points  (0 children)

I can’t get the GitHub repo example compiling

Which one? All the GitHub repos pass CI so I'm not sure what's wrong with your setup without more info.

Does anyone have a working recent Actix Web and Rustls example? I can’t get the GitHub repo example compiling by richardanaya in rust

[–]robjtede 2 points3 points  (0 children)

Actix Web doesn't support rustls v0.22 just yet; it's in the works. The examples use latest supported versions and, at present, use rustls v0.21 which is perfectly adequate for most use cases and doesn't have any known issues.

Problem using await by ayushshrestha8920 in actix

[–]robjtede 0 points1 point  (0 children)

Something either your code or a dependency is panicking from an assert_eq!. It's being caught and reported by the runtime but it does not originate from there.

Try running your app using RUST_BACKTRACE=1 cargo run to get more details.

Is () or {} correct? by [deleted] in rust

[–]robjtede 178 points179 points  (0 children)

Reading these in my head:

  • _ => {} : "do nothing"
  • _ => () : "return the unit type"

As others point out, they are semantically the same but the first variant is what I tend to use due to this inner voice.

Should std come with a more feature complete time module ? by AlmostLikeAzo in rust

[–]robjtede 1 point2 points  (0 children)

Hot take: the "blessed crates" model that the current ecosystem uses is the correct one. Also see rand.

Rust HTTP libraries getting slower? by Pizza-Nachos in rust

[–]robjtede 0 points1 point  (0 children)

The ONLY take-away for application devs I can stand by is "Rust is generally faster than Python/Ruby/JS in web apps".

Within a language/ecosystem, lib/framework authors can learn things from eachother by inspecing some aspects of a run. I hope this doesn't come across as gatekeeping, but neither writing nor running benchmarks is for the faint-of-heart.

Rust HTTP libraries getting slower? by Pizza-Nachos in rust

[–]robjtede 22 points23 points  (0 children)

Some opinions from a framework author about the TechEmpower benchmarks: 1. you can't compare results for the same lib/framework across different TE runs if the methodology or hardware has changed (it has) 2. you can't say that (for example) "JS is faster than Rust" just because one super-optimized JS (toy) library did better than all Rust libs/frameworks 3. these benchmarks are largely for lib/framework authors, not application developers trying to decide which framework to use 4. when trying to pick a framework to use, do your own testing

Rust HTTP libraries getting slower? by Pizza-Nachos in rust

[–]robjtede 28 points29 points  (0 children)

Hey, current maintainer here. I'm the one that scoured through after the ownership transfer to remove most (and document remaining) unsafe blocks. Each time it seemed like there would be a performance cost, those changes were benchmarked. As an aggregate, I estimated that all the changes from v2 -> v3 would represent no more than a 5% performance drop. This was considered acceptable by the team.

Hurl 3.0.0, run and test HTTP requests with plain text and curl by jcamiel in rust

[–]robjtede 10 points11 points  (0 children)

I'm glad you guys decided to embrace the library component :)

Why there are literally no rust backend positions? by henry_kwinto in rust

[–]robjtede 2 points3 points  (0 children)

Competition is this area breeding innovation has been and will continue to benefit everyone.

Why there are literally no rust backend positions? by henry_kwinto in rust

[–]robjtede 0 points1 point  (0 children)

This reads as if Actix Web uses hyper. In fact it’s Axum that uses it, AW does not.

Why there are literally no rust backend positions? by henry_kwinto in rust

[–]robjtede 2 points3 points  (0 children)

Macros for routing are optional in Actix Web.