{"id":19220444,"url":"https://github.com/louisbrunner/rust_intro","last_synced_at":"2025-08-17T14:48:31.791Z","repository":{"id":66205059,"uuid":"504801728","full_name":"LouisBrunner/rust_intro","owner":"LouisBrunner","description":"A basic workshop to learn Rust, ideal for groups","archived":false,"fork":false,"pushed_at":"2022-06-18T09:42:12.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-23T09:23:22.045Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LouisBrunner.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-18T09:40:41.000Z","updated_at":"2022-06-18T09:42:14.000Z","dependencies_parsed_at":"2023-05-29T18:15:32.757Z","dependency_job_id":null,"html_url":"https://github.com/LouisBrunner/rust_intro","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/LouisBrunner/rust_intro","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LouisBrunner%2Frust_intro","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LouisBrunner%2Frust_intro/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LouisBrunner%2Frust_intro/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LouisBrunner%2Frust_intro/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LouisBrunner","download_url":"https://codeload.github.com/LouisBrunner/rust_intro/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LouisBrunner%2Frust_intro/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266270438,"owners_count":23902734,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T14:35:12.304Z","updated_at":"2025-07-21T09:04:52.782Z","avatar_url":"https://github.com/LouisBrunner.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# heloworldr\n\nRefer to https://doc.rust-lang.org/book/title-page.html if you need help\n\n## Setup\n\nReference: https://doc.rust-lang.org/book/ch01-01-installation.html\n\n### Linux \u0026 macOS\n\n```bash\ncurl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh\n```\n\n### Windows\n\nDownload from https://www.rust-lang.org/tools/install\n\n## Usage\n\nYou can build the project (also used to download new crates once you add them to `Cargo.toml`)\n\n```bash\ncargo build\n```\n\nOr you can just run directly, which will rebuild if necessary\n\n```bash\ncargo run\n# or if you want to pass arguments\ncargo run -- -h\n```\n\n### Dependencies\n\nDependencies (crates) are specified in `Cargo.toml`, you can find them through Google (e.g. `rust base64`) or directly from https://crates.io/crates/, which also gives you the latest version (making it easy to add to `Cargo.toml`).\n\nYou can download `cargo-edit` using\n\n```bash\ncargo install cargo-edit\n```\n\nwhich gives you access to `cargo add` to add new dependencies, e.g. `cargo add clap` adds the `clap` crates.\n\nNote that crates can be added with `features` flags which enable/disable some features, this is usually documented on https://crates.io/.\n\n### Static analysis\n\nYou can use `clippy` for linting and `fmt` for formatting\n\n```bash\ncargo clippy # checks\ncargo clippy --fix # fixes\n\ncargo fmt --all --check # checks\ncargo fmt --all # fixes\n```\n\n## Features\n\nThe app is very basic, it only takes a name and prints Hello World with it. We would like to do much more.\n\n### Choosing the language\n\n_Themes:_ trait implementation, enums, matching, error handling\n\nCurrently, the app always replies in English. We already added a trait with one implementation for English but we would like to add another one.\n\nChoose another language and add an extra implementation, mirroring the current module structure.\n\nThen you will need to get the language from the command-line (maybe let's keep English as a default?) and use the factory to get the right implementation.\n\n### Output to a file\n\n_Themes:_ standard library usage, error handling\n\nThe app just prints to the standard output but we might want to save that result for later. Obviously we could use a simple shell redirection but it's much more fun to deal with the filesystem ourselves (isn't it?).\n\nLet's take another command-line argument and output to that file. Maybe we should check if the file exists as well and ask the user if we should overwrite it?\n\nMight be worth to add a force and interactive flag as well to allow the user to avoid that annoying prompt...\n\n### Output an image to a file\n\n_Themes:_ crate installation and usage, error handling\n\nText is all good but in a world where memes are supreme, we should really be working with images.\n\nUsing https://crates.io/crates/fontdue, we can make bitmap from text. You will need to specify the font yourself, so go wild and choose something funky from https://www.dafont.com/ (maybe you could add multiple ones and add a flag to choose between them, maybe make them themes and add color as part of it??).\n\nYou can then use https://crates.io/crates/image to save the image (and do some other manipulation, cropping, blur, etc... maybe include another image first and make an actual meme??? for reference you would be looking for the \"Impact\" font).\n\nTips: check https://github.com/mooman219/fontdue/blob/master/dev/examples/raster-print.rs#L22 and https://docs.rs/image/latest/image/enum.DynamicImage.html#method.put_pixel to learn how to transform data from `fontdue` to `image`.\n\n### Abstracting the output mechanism\n\n_Themes:_ trait definition \u0026 implementation, module creation \u0026 inclusion\n\nWell, now we have **3** different ways to output our result! A file, an image or the console... Maybe we could abstract that? Taking inspiration from the `languages` module (or not, I mean it's a free country), create your own trait and its implementations which would abstract the creation of those artifacts so that adding a new method (e.g. posting it to https://pastebin.com, which you can add as well, go wild!) is trivial and separated from the main logic.\n\nNote that module inclusion rules might be a bit peculiar/unexpected, use `super::` or `crate::` to keep your code readable.\n\n### Verbose mode\n\n_Themes:_ trait expansion, logging, matching\n\nSometimes it's nice to be able to see what the app is doing and why. Adding a verbose flag would be nice.\n\nWe could use the https://crates.io/crates/log crate (potentially paired with another crate for initialization like https://crates.io/crates/simplelog) to display the data... but what data?\n\nMaybe adding more functions to our `Language` trait which will help diagnose what it is through polymorphism (e.g. show what language it is... maybe we could even return the enum used to create it??) so we can print it from the main without adding logging everywhere?\n\n### Automatic language\n\n_Themes:_ web integration, serialization, structure definition\n\nWhat if we could add a new implementation to our `Language` trait which would automatically use an API to do the translation? More expensive (in terms of money and performance) but much more flexible! You can get a variety of crates which wrap Google Translate https://crates.io/keywords/translate, but you could even do it yourself using https://crates.io/crates/reqwest for HTTP and https://crates.io/crates/serde for JSON serialization.\n\nIn the case of Google Translate, you will need to create a project: https://console.cloud.google.com/projectcreate and enable the Google Translate API (be careful of cost and stick to the free-tier/development settings!).\n\n### Server mode\n\n_Themes:_ networking, multi-threading, serialization\n\nWell, this is all great, but in the days of the Internet, I can't be bothered to use a command-line utility, everything must be networked and _cloud_. Let's create a server which can be queried to greet us. It must be able to handle many clients at the same time because we definitely will need the scale.\n\nYou can choose the protocol, but here are some ideas:\n - Rest with JSON: using https://crates.io/crates/serde for serialization and one of the plethora of high-level web framework (https://github.com/flosse/rust-web-framework-comparison#high-level-server-frameworks) or low-level if you are feeling up to it -\u003e easy to test using cURL\n - gRPC: using https://crates.io/crates/tonic -\u003e easy to test using grpcURL\n - Do something wild! Custom TCP protocol, UDP broadcasts, Gopher, really go for it!\n\nNote that in order to parallelize client requests, you will need to use some kind of threading library... and they are a lot. You can use `std::thread` but based on the server library you choose, you might not have a choice. https://crates.io/crates/tokio is a safe choice (both `tonic` and `hyper` use it) and so is https://crates.io/crates/futures.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flouisbrunner%2Frust_intro","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flouisbrunner%2Frust_intro","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flouisbrunner%2Frust_intro/lists"}