Beginner's Guide to Rust Filesystem APIs 🦀 Rust Tutorial

preview_player
Показать описание
One of the most common operations you'll need, as a Rust developer, is the ability to read and write to the local filesystem. The standard library in Rust provides the essential functions to create / remove / rename directories, create / read / write / delete files, create symlinks, validate filesystem paths, and more. Let's dive into some of the core filesystem functionality provided by Rust!

Please follow me on these other social channels!

All trademarks, logos and brand names are the property of their respective owners. All company, product and service names used in this website are for identification purposes only. Use of these names,trademarks and brands does not imply endorsement.

#rustlang #rust #rustdev #opensource #software #linux #devops #programming #rusty #dev #coding #codinglife #code #coder #ubuntu #ubuntulinux #appdev #developer
Рекомендации по теме
Комментарии
Автор

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<String>.

tomaszsosinski
Автор

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 =

println!("File content: {:?}", content);
}

ojoawojoshua
Автор

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 :)

GrubyCh
Автор

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!

muxxxe
Автор

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 ❤

judevector
Автор

the quality of your content is really great, apreciate it bro

marlonsbardelatti
Автор

Loving this channel bro. The geek vibes are off the charts and it’s beautiful. And super educational!!

JOHNSMITH-verq
Автор

Your videos are so thorough I really enjoy that about your content!

emnul
Автор

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

jasperzanjani
Автор

very exciting video, I really appreciate your videos man, thank you alot

AhmedFalih-kjtt
Автор

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.

world-
Автор

But how to read and write binary files like in python with pickle? For example, if İ want to save an object data.

Автор

Hello brother, greetings from Argentina, are you managing infrastructure with rust? Or do you prefer other languages, such as python or golang?

fedenfer
Автор

Why does use ? At the end of the lines?

crissdell
Автор

perfect an hour on 0.75 playback speed

maylay
Автор

please integrate with actix and make google drive clone

aryabp
Автор

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.

ChidleyITCompute