Learning Rust
Learning Rust
  • Видео 172
  • Просмотров 61 907
Mimimalist Multithreaded HTTP Web Server 510kb in Rust | Rust Language
How to create the web server plus extra routes and compile down to an optimized binary in Rust. A nice follow on from the example in the Rust Book.
🟩 doc.rust-lang.org/book/ch20-02-multithreaded.html
* I didn't use a thread pool btw *
#rustprogramming #learningrust
Latest Rust Version : Version 1.79.0 as of 12 July 2024
I've added html for default route - see GitHub repo :
----------------------------------------------------------------------------------
🟩 github.com/RGGH/wb/tree/main
Make the binary even smaller with UPX :
./upx --best --lzma ~/Documents/rust/wb/target/release/wb
File size Ratio Format Name
-------------------- ------ ----------- -----------
509736 - 189456 37.17% linux/amd64 ...
Просмотров: 141

Видео

Web Scrape E-bay with Rust & Sqlite in 2024 | Rust Language
Просмотров 837 часов назад
Code to scrape ebay listings and store the results in Sqlite DB using Rust in 2024 ├── src │ ├── db.rs │ ├── main.rs │ ├── model.rs │ └── scrape.rs #webscraper #learningrust useful links : tms-dev-blog.com/rust-sqlx-basics-with-sqlite/ proxiesapi.com/articles/scraping-ebay-listings-in-rust-in-2023 ruclips.net/video/U7I7I4uINsE/видео.htmlsi=-srdkfa4fM93AJf0 github.com/RGGH/webay
Shuttle JWT tutorial | Deploy & Test | Rust Launguage
Просмотров 469 часов назад
Following docs.shuttle.rs/examples/axum-jwt-authentication ~ "Learn how you can secure your Axum web application by using JWT tokens." I deploy to shuttle and then test : /public: a route that can be called without needing any authentication. /login: a route for posting a JSON object with a username and password to get a JWT. /private: a route that can only be accessed with a valid JWT. #learni...
Learning from a Shuttle AI tutorial | Rust Language
Просмотров 15214 часов назад
Checking out the Shuttle AI tutorial for data analysis on a CSV file. Link : www.shuttle.rs/blog/2024/04/29/building-your-first-ai-tool-rust #LearningRust #RustAIproject About shuttle : "Shuttle is a Rust-native cloud development platform that lets you deploy your Rust apps for free. Check out the documentation to get started quickly: docs.shuttle.rs"
Dialoguer | Rust Language
Просмотров 8019 часов назад
Easy intro to creating a Dialog in Rust CLI ( a bit like npm ) Get the code from my repo here : github.com/RGGH/dlg Dialoguer Crate : crates.io/crates/dialoguer cargo add dialoguer "dialoguer is a library for Rust that helps you build useful small interactive user inputs for the command line. It provides utilities to render various simple dialogs like confirmation prompts, text inputs and more....
Rust-Exercises.com | Rust Language
Просмотров 184День назад
A look at using setter methods in Rust - with help from rust-exercises.com rust-exercises.com/ github.com/mainmatter/100-exercises-to-learn-rust
use closures inside a function & inside a struct | Rust Language
Просмотров 14228 дней назад
A look at using closures in a struct, and closures inside a function. I'm learning by repeating basic examples and then revisiting them and expanding upon them. Recall/Repetition! redandgreen.co.uk/closure-as-struct-member/rust-programming/ #rustprogramming #learningrust
Enum & From Trait | Rust Language
Просмотров 410Месяц назад
Learning to use the From trait with an Enum - using map to return an array of a different type. Try the code in Rust Playground: play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=3352f5b30df22d1ae16a0ea5a1978be7 #rustprogramming #learningrust #practiceRust
Learning async + await in Rust | Rust Language
Просмотров 136Месяц назад
Join me as I experiment with some non deterministic code using Async and Await in Rust. - futures do nothing unless you `.await` or poll them" - The code doesn’t wait for the tokio::task to complete, so no guarantee that part will run! - Futures are single eventual values produced by asynchronous computations. - Some programming languages (e.g. JavaScript) call this concept “promise”. 🟩 docs.rs...
How to Create Files | Rust Language
Просмотров 82Месяц назад
Short video showing the basics of creating a file in rust. doc.rust-lang.org/std/fs/struct.OpenOptions.html doc.rust-lang.org/std/fs/struct.File.html#method.create #rustlang
Is Rust better for Malware? | Rust Language
Просмотров 111Месяц назад
A look at Malware in Rust to understand if/why/how it is used "Freeze.rs is a payload toolkit for bypassing EDRs using suspended processes, direct syscalls written in RUST" - chapters - 00:00 intro 05:39 exewho2 17:09 freeze.rs 27:50 Luca Stealer I also use "cargo tree" to check dependencies. The aim of this was to view a new area of Rust without any prior knowledge. Interestingly it was good t...
MPSC Channel | Rust Language
Просмотров 82Месяц назад
I do a recap on Rust MPSC Channels - how to use them, how to create a tx and rx - sender and receive function, and how to work with timeouts. Function std::sync::mpsc::channel 🟩 doc.rust-lang.org/book/ch16-02-message-passing.html#creating-multiple-producers-by-cloning-the-transmitter Linux Hosting - VPS server - Webdock 🟩 Webdock Linux Hosting : webdock.io/en?maff=wdaff 170 #Concurrency #MPSC #...
Linked List (2nd attempt!) | Rust Language
Просмотров 93Месяц назад
After learning Rust for just over a year and doing plenty of recall - I've managed to understand and learn how to implement a Linked List in Rust. This is a run through of me typing in the code, and explaining the bits that caught me out as I was learning it. It uses a generic type T so you can use text or numbers with it! #learningrust #linkedlist
Trait Based Polymorphism | Rust Language
Просмотров 172Месяц назад
Learning to use Traits with enums and multiple structs | Polymorphism. "This Rust code defines a trait Animal with a method make_sound(). Two structs, Cat and Dog, implement this trait. An enum Pet is defined to represent either a cat or a dog. The Animal trait is then implemented for the Pet enum, delegating the make_sound() method based on the variant. A function sounds() takes a string repre...
Practising Type Constraints | Rust Language
Просмотров 518Месяц назад
This is a video showing type constraints used with with impl in a function. I show code that defines a generic function `print_iter` to print each item from an iterator that implements the `Debug` trait. The `main` function demonstrates its usage by passing iterators of vectors of different types to `print_iter`. Rust Docs: 🟩 doc.rust-lang.org/book/ch10-01-syntax.html?highlight=type constraints...
Peek and Peekable | Rust Language
Просмотров 135Месяц назад
Peek and Peekable | Rust Language
std::time::Instant | Rust Language
Просмотров 270Месяц назад
std::time::Instant | Rust Language
Closures inside functions | Rust Language
Просмотров 335Месяц назад
Closures inside functions | Rust Language
DOCX creator built with Rust docx-rs 🦀 | Rust Language
Просмотров 292Месяц назад
DOCX creator built with Rust docx-rs 🦀 | Rust Language
SurrealDB Docs + Lifetimes / Not Live Stream | Rust Language
Просмотров 2652 месяца назад
SurrealDB Docs Lifetimes / Not Live Stream | Rust Language
Generics + Where Clause | Rust Language
Просмотров 1382 месяца назад
Generics Where Clause | Rust Language
for_each v map | Rust Language
Просмотров 962 месяца назад
for_each v map | Rust Language
Unit Type | Rust Language
Просмотров 2272 месяца назад
Unit Type | Rust Language
iced project in Rust - 'guissh' | Rust Language
Просмотров 7072 месяца назад
iced project in Rust - 'guissh' | Rust Language
iced GUI | Rust Language
Просмотров 3,7 тыс.2 месяца назад
iced GUI | Rust Language
Logging with Log | Rust Language
Просмотров 2832 месяца назад
Logging with Log | Rust Language
Destructuring | Rust Language
Просмотров 1312 месяца назад
Destructuring | Rust Language
Learning about "take" with a Linked List example | Rust Language
Просмотров 1652 месяца назад
Learning about "take" with a Linked List example | Rust Language
Learning a new approach to Recursion | Rust Language
Просмотров 3213 месяца назад
Learning a new approach to Recursion | Rust Language
Live Queries SurrealDB | Rust Language
Просмотров 2273 месяца назад
Live Queries SurrealDB | Rust Language

Комментарии

  • @monkey_see_monkey_do
    @monkey_see_monkey_do 23 часа назад

    Debug vs release executable size is mind blowing!

  • @buildfromzero
    @buildfromzero 4 дня назад

    Great effort

  • @lazarmilenkovic7799
    @lazarmilenkovic7799 11 дней назад

    reupload this ,audio is bad even tho the video is good :)

  • @1____-____1
    @1____-____1 28 дней назад

    I've started using closures more and more in my code. There really powerful and just as fast as function pointers.

  • @justiceessiel6123
    @justiceessiel6123 29 дней назад

    Please make a video on how what changes to make to make it work live and how to make this work with typescript .

  • @BogdanSerban
    @BogdanSerban 29 дней назад

    What font are you using?

    • @learning_rust
      @learning_rust 28 дней назад

      I think this was JetBrains - github.com/JetBrains/JetBrainsMono

  • @jasonkristian8457
    @jasonkristian8457 Месяц назад

    you lost me as soon as you opened NV,

  • @elirane85
    @elirane85 Месяц назад

    You don't really need to implement the "from_array" method. I mean, you can, but it always seemed a bit redundant to me. There is a shorthand when using the map function on iterators if the operand signature matches the item type in the array: ``` let vehicle_array: [u32; 4] = [1, 2, 3, 4]; let vehicle_vec = vehicle_array.map(Vehicle::from); ``` So it's kinda simple without the extra method. And if you really wanna be all "fancy" and add a variadic version of the function (a function that accept an arbitrary number or parameters), you can create a macro like this: ``` #[macro_export] macro_rules! vehicle { ($($num:expr),*) => { [$(Vehicle::from($num)),*] }; } ``` Which allows you to call the function with any number of variables and get back an array like this: ``` let vehicle_vec = vehicle!(1, 2, 3, 4); ``` My approach is usually to implement as little functionality as possible to a struct. But that's just me, it's not necessarily a good or bad practice, I just like my API's as small and lean as possible.

    • @learning_rust
      @learning_rust Месяц назад

      Thank you! - " implement as little functionality as possible to a struct" - I like that approach - I'm glad you commented, appreaciate it - it's invaluable to read stuff like this. I guess the from_array method might be more suitable if it was part of a custom trait (maybe)

  • @bzimage75
    @bzimage75 Месяц назад

    which editor/IDE are you using ?

    • @learning_rust
      @learning_rust Месяц назад

      gist.github.com/RGGH/3ba6b194bef3b75186ac3cfb45890ee9

  • @phillduffy
    @phillduffy Месяц назад

    Great video again. What would the benefit of impl Animal for the structs rather than just using it on the enum? impl Animal for PetType { fn make_sound(&self) -> &str { match self { PetType::Catly => "miaow mieew", PetType::Dogly => "bow wow wow", } } }

    • @learning_rust
      @learning_rust Месяц назад

      Yes, so without the impl on the structs, I get this error : items from traits can only be used if the trait is implemented and in scope note: `Animal` defines an item `make_sound`, perhaps you need to implement it. I did try a few different approaches. I also used Box /Dynamic Dispatch with the function for pet_setup - but figured static dispatch is preferable in production?

  • @ALL-THE-SUN
    @ALL-THE-SUN Месяц назад

    the difference in timings could be because of the println!() macro maybe? what if you try the same but you do not print at line 3 and 10?

    • @learning_rust
      @learning_rust Месяц назад

      That was a great suggestion, thank you - yes, makes a big difference! - play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=1a6ceacce4bbac87c542a52335e71b97 So println! is best used only at the end, makes sense now!

    • @ALL-THE-SUN
      @ALL-THE-SUN Месяц назад

      @@learning_rust cool! I'm fairly new to Rust my self, such an enjoyable language

    • @learning_rust
      @learning_rust Месяц назад

      @@ALL-THE-SUN Yeah, can be difficult, but I like a lot - the more I learn the more I like it- I need a faster laptop to do projects on though, as compiling can take a while...

  • @ReedoTV
    @ReedoTV Месяц назад

    I would recommend not using short names or acronyms. It might seem "neater" at first, but if you have to think for even a split second about what something is, you are slowing down yourself and anybody else who reads/works on your code. Use names that are clear everywhere that variable/function/etc is used. It's annoying to have to keep scrolling back up (or jumping between files) to see what "dbaf" means, especially if you are coming back to this code 6 months later because you need to fix something or add a feature. Naming things is the hardest but most valuable skill in programming, no joke.

    • @learning_rust
      @learning_rust Месяц назад

      Thank you. I'm up to page 295 in "Rust in A Month of Lunches" and just read the part about making function names very descriptive in tests, and going to get rid of some bad habits like using "i" and "x" for variable names as well as using mnemonics for variable names. Appreciate your comment, it's really cool that you pointed it it out! Thank you!

  • @1____-____1
    @1____-____1 Месяц назад

    Oh My God!! Someone actually using match in a demo.

    • @learning_rust
      @learning_rust Месяц назад

      To be honest, I try not to use unwrap at all now...feels a bit sloppy!

  • @1____-____1
    @1____-____1 Месяц назад

    Is one action more expensive than the other?

    • @learning_rust
      @learning_rust Месяц назад

      for_each is arguably less expensive in a typical case as you'd likely be using it where you won't require a new collection

  • @user-fe8hp6jv9f
    @user-fe8hp6jv9f 2 месяца назад

    Dam just realized that I have actually never learned how to do this in rust thanks.

    • @learning_rust
      @learning_rust 2 месяца назад

      Glad it helped. Rust keeps sure does keep us all humble as no matter how much progress you make you can never be sure you've not missed something really useful or important!!

  • @scottb4029
    @scottb4029 2 месяца назад

    I completely agree that you have to go over Rust again and again

    • @learning_rust
      @learning_rust 2 месяца назад

      100% Agree. It's not easy, a bit like doing a 1000 piece jigsaw puzzle, but as pieces fit together progress does speed up. eg. for loop implicitly calls into_iter() on a collection, I only fully understood this recently. I tend study from 2 books and then strip the examples right back to the minimum and memorise the part I want to really grasp. (Usually by typing it in from scratch once a day for a few days/weeks, a bit like learning a piece of music maybe?).

  • @gitikhekra
    @gitikhekra 2 месяца назад

    Please make video series on dioxus desktop app with surrealdb embedded..

    • @learning_rust
      @learning_rust 2 месяца назад

      Ok, thank you for suggestion, I will try. I did start to use and compile SurrealDB KV store with my iced project and my poor laptop took 12 mins to compile it. I'll see how Dioxus goes.

  • @riigel
    @riigel 2 месяца назад

    great video man, thanks for sharing this

    • @learning_rust
      @learning_rust 2 месяца назад

      My pleasure. Thanks for the comment, really helps with the dreaded algorithms 👍

  • @ariseyhun2085
    @ariseyhun2085 2 месяца назад

    Really cool video thank you for sharing! I've been working heavily with Leptos which has 0.7 coming out within the next month or so, would be cool to see a video covering the release notes perhaps :D

    • @learning_rust
      @learning_rust 2 месяца назад

      Thank you! @ariseyhun2085 - I'll take a look. Expect Chris Biscardi will cover it better than I can tbh, but may be able to find something to add!

  • @aqua-bery
    @aqua-bery 2 месяца назад

    Not the entirely unrelated AI woman in the intro 😭

    • @learning_rust
      @learning_rust 2 месяца назад

      I figured the Rust foundation won't sue me for using an AI woman! 😭

    • @ariseyhun2085
      @ariseyhun2085 2 месяца назад

      AI woman in intro, AI woman in profile pic, this guy likes AI women to say the least ;)

  • @gitikhekra
    @gitikhekra 2 месяца назад

    Nice! Please come up with videos on dioxus GUI and it's integration with embedded surrealdb .

  • @riigel
    @riigel 2 месяца назад

    nice! thanks for this

    • @learning_rust
      @learning_rust 2 месяца назад

      Thank you! - appreciate the kind comment!

  • @samdavepollard
    @samdavepollard 2 месяца назад

    agreed - nice book; subbed

    • @learning_rust
      @learning_rust 2 месяца назад

      Thanks for the sub, I still really rate the book - the 2nd half of it in particular.

  • @Heater-v1.0.0
    @Heater-v1.0.0 2 месяца назад

    Since the dawn of time the pointer to the next node in a linked list has been called "next". No confusion there.

    • @learning_rust
      @learning_rust 2 месяца назад

      Thank you. I think maybe I've been tinkering with Bitcoin nodes too much, where there is a "previous block"