I know almost nothing about TOML. I’m actually more of a YAML “man”.
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 move
s 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 move
d 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.
HttpServer::new(move || { [1] }).bind[2].run().await?;
is the basic structure. [1] consists of two parts,
context
and rate_limiter
variablesApp: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.
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.
…
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.
I’m going to tackle Rust from a variety of angles, one of which is by studying Lemmy.