I know almost nothing about TOML. I’m actually more of a YAML “man”.

  • 2 Posts
Joined há 6 meses
Cake day: nov 07, 2021


I’m going to tackle Rust from a variety of angles, one of which is by studying Lemmy.

So I think I figured a few things out.

HttpServer::new(move || {...}) is doing a few things. First, HttpServer is calling a method new which moves the context (settings_bind) into a closure ({...}), which is kind of like a local-use function. The || denotes that no variables are being passed into the closure. Instead, the context is being moved in so I guess it can be destroyed once the scope of HttpServer disappears.

App::new() must refer to a method of HttpServer but I haven’t investigated that yet. I suspect .run() applies the App construct, whatever it is.

Initial observations

HttpServer::new(move || { [1] }).bind[2].run().await?; is the basic structure. [1] consists of two parts,

  1. Defining the context and rate_limiter variables
  2. Setting up something called App:new()

We see context being loaded as .app_data in App::new(), and rate_limiter being loaded into the config.

Then routes are added.

Part of what is unusual to me is defining variables within the server setup. But this may have something to do with the way Rust deals with variables. Since context has no meaning outside of this setup, better to use it here and throw it away once we’re done setting up the HttpServer?

Whereas App::new() dealt with Lemmy specific app configuration and behavior, .bind appears to involve more generic HttpServer configuration stuff [2], including the port to bind to.

Then the whole thing .run()s, and then .await?s for multithreading.

Task one: comprehend HTTP server startup in main.rs

Coming from a bash scripting background, Rust’s syntax is mind boggling. The code from HttpServer... to await? is a single object. Trying to figure out how it works is going to be my first task. …

Here color indentation is clear because it’s a single reply thread.

The colored indentation on replies… underperforms. Multicolor is a tad confusing, and it’s not always clear what is replying to what.

The left hand indentation on comments is inadequate.

Syntax highlighting doesn’t work, which is unfortunate.

Test posting of lemmy-main/src/main.rs

Test to see how source code looks on Lemmy. …

I hope it fails so Americans can spend the next century making plastic junk for the Chinese middle class. I love how Intel is rebranding it’s 7nm vaporware process as “Intel 4” so it can sound like it’s better than TSMC’s 5nm process. Notwithstanding the hope that full integration between capitalism and the military industrial complex can bring, the above laughable rebrand reveals much about the heart and soul of American power: today, after all the torture chambers and war of terror, the death and displacement of millions of people around the world to prop up Dick Cheney’s “American Way of Life”, we peripheral peoples get to witness America’s humiliating descent into self-parody and delusion.