- 192
- 83 262
Learning Rust
United Kingdom
เข้าร่วมเมื่อ 2 ต.ค. 2020
A regular series of videos covering the progress of me capturing what I learn as I take on Rust!
redandgreen.co.uk/category/rust-programming/
Discord channel now up and running!!
discord.gg/pBzuyNpF85
redandgreen.co.uk/category/rust-programming/
Discord channel now up and running!!
discord.gg/pBzuyNpF85
cargo watch 👀 | Rust Language
Using 'cargo watch' to iterate fast. Credit to Jeremy Chone for teaching me this in his Axum video!
cargo watch -q -c -w src/ -x run
q = quiet
c = clear
w = watch
x = excute
Watches over your Cargo project’s source
------------------------------------------------------------------
🟢 crates.io/crates/cargo-watch
View the code / commands / screenshots here :
🟢 redandgreen.co.uk/rust-quick-dev-httpc/bitcoin-programming/
Credit : Jeremy Chone 👀
🟢 th-cam.com/video/XZtlD_m59sM/w-d-xo.htmlsi=6bqJaMMRQFAPWcaM
WEBDOCK Linux VPS Hosting :
-----------------------------------------------------------------
🟢 webdock.io/en?maff=wdaff--170
#rustlang #rustforbeginners
cargo watch -q -c -w src/ -x run
q = quiet
c = clear
w = watch
x = excute
Watches over your Cargo project’s source
------------------------------------------------------------------
🟢 crates.io/crates/cargo-watch
View the code / commands / screenshots here :
🟢 redandgreen.co.uk/rust-quick-dev-httpc/bitcoin-programming/
Credit : Jeremy Chone 👀
🟢 th-cam.com/video/XZtlD_m59sM/w-d-xo.htmlsi=6bqJaMMRQFAPWcaM
WEBDOCK Linux VPS Hosting :
-----------------------------------------------------------------
🟢 webdock.io/en?maff=wdaff--170
#rustlang #rustforbeginners
มุมมอง: 98
วีดีโอ
ok() | Rust Language
มุมมอง 275หลายเดือนก่อน
Result to an Option - conversion using .ok() play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=25bc2b3e3ecde87485b8fcb9d57dd5dc #learningrust #result
Iced MVP | Rust Language
มุมมอง 238หลายเดือนก่อน
This video is a quick round up covering iced 0.13 - window position, Task, and run_with Make an API request (async) and display the response (tuple) in the view. The app fetches the latest Bitcoin price in £ and $ th-cam.com/play/PL38rDfx7QwKZBQ2wif-wvFUvmP2QMXWjx.html Feel free to copy/refer to my code. github.com/RGGH/aice [dependencies] iced = {version="0.13.1", features = ["tokio","image"]}...
iced.rs 0.13 | Fetch BTC | Rust Language
มุมมอง 394หลายเดือนก่อน
Demo of an app made with iced.rs - fetch BTC price. I also show some examples of using rows, columns, containers, and window positioning. th-cam.com/play/PL38rDfx7QwKZBQ2wif-wvFUvmP2QMXWjx.html - chapters - 00:00 intro 01:00 article with code 02:10 row 03:00 column 04:00 align center 04:58 centre the window 9:32 fetch btc price redandgreen.co.uk/iced-rs-example-snippets/rust-programming/ 👀 code...
Parsing Text | Rust Language
มุมมอง 552หลายเดือนก่อน
parsing text - I show 2 examples to get the same result - in the second we shift to a more functional style. Rust playground example : play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=421bb5681a88bfa01ad61b01233519f0 Linux VPS Hosting : 🟢 webdock.io/en?maff=wdaff 170 #learningrust #functional
iced GUI + Database | embedded surrealkv | Rust Language
มุมมอง 521หลายเดือนก่อน
In this video I show the code and demonstrate my Rust project using iced GUI and an embedded database (SurrealKV). The latest version of iced has a few changes, and I also show how I used tokio / async within the iced structure. SurealDB playlist : th-cam.com/play/PL38rDfx7QwKaluI7PoOrjlmjGTgx45C2Y.html iced GUI playlist : th-cam.com/play/PL38rDfx7QwKZBQ2wif-wvFUvmP2QMXWjx.html - chapters - 00:...
Surrealkv | Embedded | Rust Language
มุมมอง 410หลายเดือนก่อน
SurrealKV database that you can embed in your own Rust project. 🦀 "surrealkv is a versioned, low-level, persistent, embedded key-value database implemented in Rust." github.com/surrealdb/surrealkv github.com/surrealdb/surrealkv?tab=readme-ov-file#transaction-operations Features ✨ ACID Compliance: Full support for Atomicity, Consistency, Isolation, and Durability 🔄 Rich Transaction Support: Atom...
digital signatures | ed25519 | Rust Language
มุมมอง 207หลายเดือนก่อน
In this video I use Ed25519 to create a keypair and show the bytes/hex output. I refer to notes for some of this, but forgive me as you can typically copy and paste a lot of it when you need it. ✅ cargo add ed25519-dalek code : ✅ gist.github.com/RGGH/1b5e5d51bd8e5bf4179539e716bc0cfa Ed25519 is a specific instance of the Edwards-Curve Digital Signature Algorithm designed for high performance and...
match self | Rust Language
มุมมอง 1452 หลายเดือนก่อน
In this video I use match self with an enum and impl fmt::Display Note the need to use the display trait on the enum as well? "In Rust, the match self pattern is often used within an impl block for a type to handle different variants of an enum or different states of a struct. It’s a way to use pattern matching on the self value of a method, which is especially useful when dealing with enums." ...
Prototype Pattern | Rust Language
มุมมอง 1852 หลายเดือนก่อน
The key points of the Prototype pattern - cloning objects, polymorphism, and reuse of existing objects. Rust Playground code : play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=85fe77b5f11c48b87af84404e9cdf9ab Design Patterns Playlist : th-cam.com/play/PL38rDfx7QwKYgpIWxEC6Cq2e_b3L8jEy7.html refactoring.guru/design-patterns/prototype/rust/example Design Patterns? 🟢 Check out : ref...
Closures #2 | Rust Language
มุมมอง 1492 หลายเดือนก่อน
In this Rust tutorial, we'll explore a simple example of higher-order functions and closures. The `take_2` function accepts two integers and a closure as arguments, then applies the closure to the integers. We define a closure that multiplies two numbers and pass it to `take_2`, demonstrating how Rust handles functions as first-class citizens. code : play.rust-lang.org/?version=stable&mode=debu...
Learning the Adapter Pattern | Rust Language
มุมมอง 2782 หลายเดือนก่อน
In this video I attempt to learn a classic design pattern - the ADAPTER pattern - (these were "formulated" by the “Gang of Four” (or simply GoF) in 1994). For more detailed explanations, this is very helpful : 🟢 refactoring.guru/design-patterns WEBDOCK Linux VPS Hosting : 🟢 webdock.io/en?maff=wdaff 170 My code: 🟢 gist.github.com/RGGH/337e690dc8de3c3f73188c5ab5706262 Rust Playground 🟢 play.rust-...
Factory Pattern in Rust | Rust Language
มุมมอง 2212 หลายเดือนก่อน
The factory pattern is a design pattern in programming that helps create objects (or instances of classes) without telling the code exactly which kind of object to make. redandgreen.co.uk/factory-pattern-in-rust/rust-programming/ Need a proxy solution? Try ScrapeOps - 10% off with code = "Python360" 🟢 scrapeops.io/?fpr=ken56 WEBDOCK Linux VPS Hosting : 🟢 webdock.io/en?maff=wdaff 170 #DesignPatt...
Design Patterns | Rust Language
มุมมอง 2702 หลายเดือนก่อน
An initial Review of Alexander Shvets Design Patterns book. refactoring.guru/store Very impressed! #rustlang #designpatterns
Stack Machine | Rust Language
มุมมอง 1662 หลายเดือนก่อน
Coding a toy Stack Machine with Op Codes in Rust Linux Hosting - VPS server - Webdock 🟩 Webdock Linux Hosting : webdock.io/en?maff=wdaff 170 #rustlang #OpCodes
Actix-web | Shared State | Rust Language
มุมมอง 1923 หลายเดือนก่อน
Actix-web | Shared State | Rust Language
Learning About Nibbles | Rust Langauge
มุมมอง 923 หลายเดือนก่อน
Learning About Nibbles | Rust Langauge
Convert Result to Option (Some or None) | Error Handling | Rust Language
มุมมอง 1414 หลายเดือนก่อน
Convert Result to Option (Some or None) | Error Handling | Rust Language
WebSocket Server in Rust | Rust Language
มุมมอง 7264 หลายเดือนก่อน
WebSocket Server in Rust | Rust Language
Mimimalist Multithreaded HTTP Web Server 510kb in Rust | Rust Language
มุมมอง 7474 หลายเดือนก่อน
Mimimalist Multithreaded HTTP Web Server 510kb in Rust | Rust Language
Web Scrape E-bay with Rust & Sqlite in 2024 | Rust Language
มุมมอง 2114 หลายเดือนก่อน
Web Scrape E-bay with Rust & Sqlite in 2024 | Rust Language
Shuttle JWT tutorial | Deploy & Test | Rust Launguage
มุมมอง 794 หลายเดือนก่อน
Shuttle JWT tutorial | Deploy & Test | Rust Launguage
Learning from a Shuttle AI tutorial | Rust Language
มุมมอง 2254 หลายเดือนก่อน
Learning from a Shuttle AI tutorial | Rust Language
use closures inside a function & inside a struct | Rust Language
มุมมอง 1715 หลายเดือนก่อน
use closures inside a function & inside a struct | Rust Language
Learning async + await in Rust | Rust Language
มุมมอง 1705 หลายเดือนก่อน
Learning async await in Rust | Rust Language
That was using TMUX and Neovim. I also use powerline 10k + my-zsh 👍
Hi, thank you for video. What's editor use please on terminal ?
The todos example simply saves to a json file.
Thanks, I've been searching for some days, trying to work out how to initialise an Iced window to show non-default values. There was enough here to answer my question.
Glad it helped 👍 ChatGPT isn't often much help with iced 0.13 so I thought I'd share 🙂
Should have named the cat with 3 legs "Tripod".
This is why I love the comments 👀👍
Ai generated thumbnail is an instant dislike though
lol
nice one lad, curious about your progress you got a roadmap for upcoming videos or projects? something bitcoin related?
Not sure yet, might revisit BDK and make something with iced + BDK, also thinking about doing some leetcode/codewars examples
Thank you for trying it out. Just having a detailed look. I just wanted to mention that 2.0.3 has some major improvements to surrealkv (0.3.7) which fixes a major issue with range scans. You should see much higher range query speeds.
Ah great. I'll check it out as the range scan was a feature I want to learn in due course. Thank you for the comment. Very much appreciated.
@@learning_rust Pleasure! Please feel free to raise any issue if you have questions :)
can you do dioxus + database too?
I'd love to, my laptop fan starts going mad when I compile it though - I definitely want to do a project with it, I may need to invest in a new computer soon.
@@learning_rust same lol
Nice one. I’m going to try if I can encrypt & decrypt io/files based upon this principle
Ah yes, as opposed to just digitally sign? 👍
@@learning_rust yes. Let’s see if i can store it in a file somehow
I think I will never be able to use neovim: at 5:57, if I write `let payload = b"Hello World";`, JetBrains IDE will show me the type of `payload` while neovim shows nothing.
At 4:49, is this neovim configured properly? When `signing_key.` is typed, I expect neovim to show me the method names that I can use with that signing_key (i.e. `verifying_key`) instead of the words that already exist in this file (`Verifier`, `VerifyingKey`).
well spotted, yes, that does work on my other laptop, I used this one for recording. I need to compare init.vim files, and get this one to do show method names.
At 4:44, `SigningKey::generate(&mut csprng)`: the `&mut` means that this function will modify the argument? If that's true, this is a very bad function, IMO. I always try not to modify the arguments of a function. If we want to modify the argument, then the argument will stay untouched and the modified version of that argument will be returned. Maybe I use Java too much where we don't think about the memory when creating a new object from an existing one.
In Rust it is quite common to modify the argument in-place as the '&' means it's a reference so it saves duplicating - but, if you prefer more functional programming style you can use "clone" but that can be more expensive.
This neovim seems to be very inferior to RustRover, I guess. If I type `use ed25519_dalek::`, I expect RustRover to give me some name that I can use there (not sure if RustRover is able to do that now, but that's what IntelliJ can do).
u can cast this as const raw pointer &x as *const u8 to get readable raw pointer &mut x as *mut u8 to get mutable raw pointer we can change variable's content using std::ptr::write(&mut x as *mut u8,69)
Ah cool, thank you. std::ptr::write 👍
That's not a ThinkPad. I'm not watching this.
🤣👍
nice
So, Rust supports at least some of the classical C bit twiddling operations (<<, >>, | and &). Good to know.
Shouldn’t the factory return an instance of the Pets object instead of the trait? Seems to be a rather limited approach like this.
Ok, so return... -> impl instead? 'static dispatch' still learning - so all advice welcomed
Something like this? play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=5cb6d0dc5698d7ed189ea366d6fd4b1d
@@learning_rust Yeah, my understanding of the factory pattern is that you shouldn't worry about the exact implementation. That's where the factory comes in. But I usually use design patterns fairly loosely (when I use 'em) See my other remark on what I did with it. Your stuff is really inspiring to play with the concepts
@@learning_rust Yes, that was my interpretation too
Understood I'm trying to nail the theory, and then deviate/use more loosely exactly like you say, I'm going to revist "Rust in a Month of Lunches" page 244 (I'm not on any commission, but it's such a good book). Thanks for taking the time to comment 👍
lifetimes is really tricky for me, i also just use String instead of a &'a str 😅
Yeah, I think you can avoid using them *most* of the time!
Hi, let's assume I have a scenario where there is a customer table, and I want to update a `customer` table, but all the fields in the customer table might not be updated at everytime. How do I make the tables update-able in SurrealDB.
UPDATE / SET... Something like this : UPDATE customer SET email = "newemail@example.com" WHERE id = "customer123"; and the you could leave name, phone number, address unchanged for instance?
@@learning_rust hi, thanks for reaching out. I already fixed this. I used ‘patch’ & “pathop”. I’m enjoying it, thanks.
ty! this is a nice way to practice using enums inside match. Appreciate the large fonts! 😉
Glad you like it!
Looks cool
_________________ I used this as a default, still works fine
Can you show how to fetch data from ethereum blockchain using RUST
I need to watch that 7 times, at least… 😂
tbh, the link to the code is in the description - that might be easier to unpick!
@@learning_rust the code isn’t the problem, it’s getting my head around the arc/mut thing
I studied the example in the rust docs and then typed it out over and over until I could do it from memory. Tbh, I probably knew how to type the code before I fully understood it! As long as you remember that you're cloning the reference, rather than the data that really helps. Also, you have multiple threads that have access to the data, but the mutex is making sure only one thread can edit the shared data and any given moment. I'm still learning this, it's not easy is it! ps. I still try and type this from memory maybe once a month, even if I've been doing something else : gist.github.com/rust-play/134777f5c866babddbd6464d82d04d14
In Java, there's a ConcurrentHashMap will can be accessed by multiple threads at the same time. If there's something like that in Rust, that'll be excellent. That Arch<Mutex<...>> scares me.
Yes, not part of the standard library, as you may have noticed the standard library is deliberately kept slim, but there's a crate available : crates.io/crates/dashmap "DashMap is an implementation of a concurrent associative array/hashmap in Rust."
We have only 1 instance of PgPool and cache, right? If yes, they can be a global variable and don't need to be passed to the get_user function as argument.
Yes, correct. They could be made global variables, that would eliminate the need to pass them as arguments to the get_user function, But..there's always a but isn' there? As I understand it, "using global variables in Rust is *generally discouraged* because it can lead to issues with thread safety + testing"
@@learning_rust thread safety: even when you pass it to the route handler, you have to deal with thread safety too, right (because there'll be multiple requests coming to the app at the same time)? testing: yes and no. Yes: it seems that if we use a global variable, we cannot mock it and pass the mock to the route handler. No: in this particular case, I prefer not to mock postgres. We can use testcontainers to spin up a postgres server when running tests and the PgPool will use that postgres in the docker container. That requires PgPool being able to connect to a postgres server specified in some system properties (system properties is a concept in Java, it's not environment vars, not sure if Rust has something similar).
@@avalagum7957 Yes, when you pass PgPool (a database connection pool) or a cache to a route handler, you do still need to handle thread safety. (Arc). + Yes, there is this crate : "testcontainers v0.21.1" - 'A library for integration-testing against docker containers from within Rust'. + No, there isn’t a direct equivalent to Java's "system properties," but I have read this elsewhere : "Rust's approach is more in line with Twelve-Factor App principles, which emphasize using environment variables for configuration, especially in the context of cloud-native and containerized applications."