January 2018
Beginner to intermediate
454 pages
10h 8m
English
Since we can get different types of errors and we want to keep track of all of them, we'll create a custom error type. Let's create a new module in which we'll put this new type:
mod error;
Add it to the src/error.rs file:
use std::io; use std::str::Utf8Error; use std::string::FromUtf8Error; pub enum Error { FromUtf8(FromUtf8Error), Io(io::Error), Msg(String), Utf8(Utf8Error), }
Here, we have an enum representing the different errors that can happen in our FTP server to be implemented. There are UTF-8 errors since FTP is a string-based protocol and I/O errors because we communicate over the network and communication issues can happen. We created variants for error types coming from the standard library, which will be helpful ...
Read now
Unlock full access