Some examples of snippets I use a lot. Helped me get started and hope it will help others as well.
-
Run
curl https://sh.rustup.rs -sSf | sh
-
then make sure Cargo is in your path by adding this to your profile:
export PATH="$HOME/.cargo/bin:$PATH"
. I use oh-my-zsh so I just donano ~/.zshrc
then add that line to the bottom via CTRL + W and then CTRL + V to get to the bottom quickly, or you could just echo it to .zshrc viaecho 'export PATH="$HOME/.cargo/bin:$PATH"' >> ~/.zshrc
.
From the root folder simply run cargo build
and it will build every sub directory package. Then explicitly run with -p
the specific package you want to run, e.g., cargo run -p tcp_server
.
For each folder, cd into the folder and run cargo build
then cargo run
and it should work fine.
below are the examples in each subfolder under the main repo
Starts a local server on port 9123.
You can quickly netcat a message to it and it should respond back like this:
echo 1 | netcat localhost 9123
A simple example where it asks for a number input and it prints out the number you selected.