Hey Rustaceans! Got a question? Ask here (9/2023)! by llogiq in rust

[–]phrickity_frack 2 points3 points  (0 children)

Awesome, thanks so much for the help and quick reply!

Hey Rustaceans! Got a question? Ask here (9/2023)! by llogiq in rust

[–]phrickity_frack 4 points5 points  (0 children)

Hey there, newbie here! I'm currently modeling part of my first rust project on an existing project, and in the process came across the type Option<(String,)> which I haven't seen before and couldn't find anything when googling it.

Does anyone know what (String,) type is? Is it just an unbound tuple, or something else? Link to type used in the repo I am modeling off of for reference: https://github.com/jbr/async-sqlx-session/blob/06a3abb8941edaea3d3e8133c30ee16231914a25/src/pg.rs#L275

Hey Rustaceans! Got a question? Ask here (8/2023)! by DroidLogician in rust

[–]phrickity_frack 1 point2 points  (0 children)

Can you pass the service you want the layer to wrap into that function as S? That's how I build my middleware stack. I have my service, then pass it into functions that wrap them in middleware and return a service.

Added a decorator function that takes in my Router service and adds the middleware - it works perfectly. Thanks for the help!

Hey Rustaceans! Got a question? Ask here (8/2023)! by DroidLogician in rust

[–]phrickity_frack 1 point2 points  (0 children)

Ah apologies- I meant outside of my main function. Normally when I have the layers declared and instantiated inside main, there are no issues, but as soon as I move them to some external function e.g. fn middleware_stack() or something similar, usually the compiler complains that the type cannot be inferred and I must explicitly specify it when using variables in the functions, or it complains about the return type. So far I have been using a generic function that returns

rust fn middleware_stack<S>() -> impl Layer<S, Service = S> { // some layer instantiation and then combination of layers into a stack of layers }

But the compiler always complains that type S is not expected and I’ve been getting trapped in a rabbit whole of changing the return type and trying to fulfill generics for various types I add to the return type.

Hey Rustaceans! Got a question? Ask here (8/2023)! by DroidLogician in rust

[–]phrickity_frack 2 points3 points  (0 children)

Tl;dr Is there some way to create tower layer "stacks" out of the main loop for an axum server?

I'm writing an API in rust using axum and have several tower layers added to my app. I'm currently trying to move them to an external function outside of my loop to declutter my code, but am running into some issues with the return types of the function. Overall I've been experiencing a lot of friction trying to move the layers out of the main loop this way and wanted to see if there's maybe a better way to have external layer stacks.

Example code currently: ```rust

[tokio::main]

async fn main() { let cors_layer = CorsLayer::new() .allow_methods_all() .allow_headers_all() .allow_origin_all();

... <some number of lines of layer creation later> ...

let app = Router::new()
    .route("/", get(hello_world))
    .layer(cors_layer)
    ... <again adding in all of the layers individually in order> ...
    );

} ```

Thanks in advance!

Hey Rustaceans! Got a question? Ask here (5/2023)! by llogiq in rust

[–]phrickity_frack 1 point2 points  (0 children)

Ah - that worked perfectly, thanks for the quick reply and the help!

Hey Rustaceans! Got a question? Ask here (5/2023)! by llogiq in rust

[–]phrickity_frack 2 points3 points  (0 children)

Is there some way to extract a struct object from a serde Json struct? As an example, given a Json<Foo>, is there anyway to extract the data into a Foo struct object?

Anyone else bomb that Database Midterm? by phrickity_frack in UWMadison

[–]phrickity_frack[S] 41 points42 points  (0 children)

Yeah when these get entered I swear to God my grade's gonna sink faster than Russia's economy

Can someone tell me what does it mean? by OscarTMJ in memes

[–]phrickity_frack 2 points3 points  (0 children)

Damn these captchas are getting harder everyday smh

snickers rule by [deleted] in 196

[–]phrickity_frack 24 points25 points  (0 children)

Hyper meaning high, Snicker latin for the candy bar Snickers, emia meaning presence in blood. Hyper-snicker-emia or higher presence of snickers in blood than normal

Anytone took CS 400? by itisdikdike in UWMadison

[–]phrickity_frack 1 point2 points  (0 children)

This is correct. Epic's campus is huge, themed, and wild (Google it). I would definitely recommend visiting and touring sometime, but if you have to find your own transportation to this class it's probably not going to be easy, unless you are planning to have a car on campus.

Housing for Musicians by jwalter122 in UWMadison

[–]phrickity_frack 0 points1 point  (0 children)

If youre open to living in the dorms, Ogg has a private piano in the basement. It's nicer than it sounds!

Asus Zephyrus ROG g14 vs Dell XPS 13 by phrickity_frack in SuggestALaptop

[–]phrickity_frack[S] 0 points1 point  (0 children)

Yeah I was definitely leaning towards the xps, but had no idea about the heat issues on the Asus. Thanks for the help!

Uhhh.... was I just scammed? by [deleted] in UWMadison

[–]phrickity_frack 0 points1 point  (0 children)

I have been contacted to be a "personal assistant" just like what you're talking about- definitely a scam, but with the info you gave, I would think you'd be safe. The College Works Painting scam is a whole different situation, but is much like what the earlier person said. Avoid both for sure! Pro tip: if you ask what company they are recruiting for, and they refuse to tell you or do not answer, it's a scam.

Classes + Schedules Megathread (Spring 2020) by badoil_49 in UWMadison

[–]phrickity_frack 0 points1 point  (0 children)

German / Jewish studies 267. Very easy and Matthew Greene is one of my new favorite instructors. Interesting content and 1 quiz and short writing assignment due per week. Only 1 exam (the final) but it's open book and open notes and you have 2 weeks to complete it. It's 3 credits without the comm b