Beginner's Guide to Rust Filesystem APIs 🦀 Rust Tutorial

  Рет қаралды 15,878

Trevor Sullivan

Trevor Sullivan

Күн бұрын

Пікірлер: 40
@tomaszsosinski5935
@tomaszsosinski5935 Жыл бұрын
Hi Trevor, thank you for creating this content. I would like to make one comment about the video. I believe reading raw bytes from file and converting them to chars and string via fold on iterator might be a bit daunting to some viewers. I see the value in it as it shows low level mechanism, however, I would add another minute or two to video to show `std::fs::read_to_string` function that does conversion of bytes to String behind the scenes. I also think that the video on `std::fs::File` should contain examples on using `std::io::BufReader` to read contents of file to a Vec.
@TrevorSullivan
@TrevorSullivan Жыл бұрын
Hello Tomas, that's a good idea! Thank you for taking the time to write out your thoughts. I agree that reading raw bytes from a file can be daunting for someone who's new to programming. Cheers 🙂
@Gruby7C1h
@Gruby7C1h Жыл бұрын
Small correction for part around 24:07 -> the std::fs::write does return useful info (try to create a file in unexisting directory for example). You only see unit as a result because here the result is actually std::io::Result which always has std::io::Error as Err value. Nice channel btw :)
@ojoawojoshua780
@ojoawojoshua780 Ай бұрын
I thought I was the only one, it captures the error as well, thank you Trevor
@ojoawojoshua780
@ojoawojoshua780 Ай бұрын
This is nice Trevor, but instead of going through the hassle of iterating and creating a closure, there is a method call "read_to_string" on the fs module fs::read_to_string, which does the conversion, so we can have : pub fn test_read_file() { let file_path = "./data/test.txt"; let content = fs::read_to_string(file_path).unwrap(); println!("File content: {:?}", content); }
@TrevorSullivan
@TrevorSullivan Ай бұрын
@@ojoawojoshua780 thanks for pointing that out!
@muxxxe
@muxxxe Ай бұрын
Great video Trevor! I'll be bingeing your channel for the next few months :). Im working towards rust mastery and I love the way you teach! Thank you!
@TrevorSullivan
@TrevorSullivan Ай бұрын
@@muxxxe thanks so much!!! I appreciate your support. I would love to create some new content, although I work full-time and have some pretty severe chronic health problems that limit me from doing so.
@marlonsbardelatti202
@marlonsbardelatti202 Жыл бұрын
the quality of your content is really great, apreciate it bro
@emnul8583
@emnul8583 4 ай бұрын
Your videos are so thorough I really enjoy that about your content!
@judevector
@judevector Ай бұрын
This is really nice , I really learnt and loved how you broke down the reading of file. While going through this video i noticed that using the read method it doesn't read emojis . I also learnt there is also a read_to_string method in the rust documentation Regardless this is a great video, thanks. I am unto the next one in the playlist ❤
@JOHNSMITH-ve3rq
@JOHNSMITH-ve3rq Жыл бұрын
Loving this channel bro. The geek vibes are off the charts and it’s beautiful. And super educational!!
@AhmedFalih-kj3tt
@AhmedFalih-kj3tt Жыл бұрын
very exciting video, I really appreciate your videos man, thank you alot
@deverse
@deverse Жыл бұрын
loving this channel
@jasperzanjani
@jasperzanjani 5 ай бұрын
I was about to say you should have used an if let or even a match statement but I guess it's kind of clever avoiding that syntax for the sake of beginners
@TrevorSullivan
@TrevorSullivan 5 ай бұрын
@@jasperzanjani yeah, match makes sense but I always get tripped up by if.. let, even after a year
@nicolaswolyniec1354
@nicolaswolyniec1354 Жыл бұрын
thanks for the video! I enjoyed it!
@RichardWalterLanda
@RichardWalterLanda 5 ай бұрын
THANKS for your videos
@NSA.
@NSA. 3 ай бұрын
Thank you mann
@daniil2704
@daniil2704 Жыл бұрын
35:00 String::from_utf8(read_result.unwrap())
@nhwhn
@nhwhn 9 ай бұрын
thank you for the great contents
@world-9644
@world-9644 3 ай бұрын
Can someone help me? I made a simple rust program that reads a json file and prints the contents. Cargo run works totally fine, but when I run the executable, it says it cannot find the json file, even when it’s in the same directory. I want to be able to make a change to the file, run the executable, and see those changes, so I need the JSON to be separate from the bundled exe. How do I do this? Can’t find any answers online.
@le0nz
@le0nz 3 ай бұрын
Don't use relative paths, a easy way to debug is print the root of your dir so you see it's not the same as the root of the cargo project
@kafuu1
@kafuu1 6 ай бұрын
u are the hero
@pratikkulkarni891
@pratikkulkarni891 Жыл бұрын
Thank you.
@fedenfer
@fedenfer Жыл бұрын
Hello brother, greetings from Argentina, are you managing infrastructure with rust? Or do you prefer other languages, such as python or golang?
@TrevorSullivan
@TrevorSullivan Жыл бұрын
Hello! Thanks for your question. I am not currently using Rust to manage infrastructure, but I think it would be an excellent language to use for that purpose! If you are wanting to use something "off the shelf," then Salt, Ansible, and existing tooling might be your best bet though.
@crissdell
@crissdell 4 ай бұрын
Why does use ? At the end of the lines?
@TrevorSullivan
@TrevorSullivan 4 ай бұрын
In cases where a Result is returned by a function call, the ? will unwrap the result or surface the Error up to the caller. This requires that the function has the Result type as a return value though. I'm sure the documentation covers this better than I can in a comment, so I'd read more about it there.
@TrevorSullivan
@TrevorSullivan 4 ай бұрын
doc.rust-lang.org/rust-by-example/std/result/question_mark.html
@piyushpatil6874
@piyushpatil6874 9 ай бұрын
Love from India ❤❤❤
@736939
@736939 8 ай бұрын
But how to read and write binary files like in python with pickle? For example, if İ want to save an object data.
@TrevorSullivan
@TrevorSullivan 8 ай бұрын
That's a great question! Great idea for another video
@736939
@736939 8 ай бұрын
@@TrevorSullivan Thank you, it would be the great tutorial :)
@ibrahimyıldız-i3q
@ibrahimyıldız-i3q 6 ай бұрын
great!
@maylay3775
@maylay3775 Жыл бұрын
perfect an hour on 0.75 playback speed
@aryabp
@aryabp Жыл бұрын
please integrate with actix and make google drive clone
@kotazkozla253
@kotazkozla253 3 ай бұрын
yapper
@ChidleyITCompute
@ChidleyITCompute 9 ай бұрын
This is very helpful. Thankfully rust handles utf8. I learned a lot from this (and your other) video: that's my goal and you're delivering it.
@TrevorSullivan
@TrevorSullivan 9 ай бұрын
Thanks so much for your kind comment! 😊❤️🦀
Overview of Rust Cargo Tool 🦀📦 Rust Tutorial
28:06
Trevor Sullivan
Рет қаралды 7 М.
黑天使被操控了#short #angel #clown
00:40
Super Beauty team
Рет қаралды 61 МЛН
СИНИЙ ИНЕЙ УЖЕ ВЫШЕЛ!❄️
01:01
DO$HIK
Рет қаралды 3,3 МЛН
The Rust Standard Library is SO Confusing...Until Now!
11:45
Travis Media
Рет қаралды 32 М.
Rust's Alien Data Types 👽 Box, Rc, Arc
11:54
Code to the Moon
Рет қаралды 155 М.
All Rust string types explained
22:13
Let's Get Rusty
Рет қаралды 192 М.
Rust Data Modelling Without Classes
11:25
No Boilerplate
Рет қаралды 184 М.
Andrew Kelley   Practical Data Oriented Design (DoD)
46:40
ChimiChanga
Рет қаралды 151 М.
Rust's Most Important Containers 📦 10 Useful Patterns
17:11
Code to the Moon
Рет қаралды 131 М.
I made my own Text Editor (in Rust)
8:16
FaceDev
Рет қаралды 139 М.
why rust libraries may never exist.
7:26
Low Level
Рет қаралды 288 М.