To start off our program, we are going to create a new library project using cargo new, and then I'm
going to call my program chat and then we will use the lib parameter and now we can change into that
directory.
And I want to just go ahead and clear out some of this filler code.
Some of the first things that I want to do is add a couple of dependencies that we are going to need
throughout this project.
The first one is async standard.
Latest version one, I would like to use Tokyo.
We're going to use the latest version one.
And then we can also specify the features that we want.
And in this case, we want sync.
I also want Saturday
version latest of one.
And features equal drive and are see.
Features.
And then the last one.
Saturday, Jason.
The latest version of one.
So async standard we are familiar with since we've already used it.
And Tokyo is another collection of asynchronous primitives, which is kind of like async standard.
It is a well known and very widely used crate and it's a pretty large crate.
So since we only need one component from it, we can specify features, which is what we did.
And then we said, Hey, we want sync.
So what that's what cargo's going to do is it's only going to provide us sync from the Tokyo crate.
That way we don't absorb in everything else that comes with Tokyo.
We only get what we need.
And then we have Saturday and Saturday JSON and these are crates that give us easy and efficient tools
for generating and parsing JSON, which is what our chat is going to use to represent data going over
the network.
So now we can create a few additional files and directories to kind of finish setting up our project.
So inside source, we're going to want a new file and we're going to call it Utils.
And then we also want a new directory called Bin for binary.
And then inside of this folder, we want our client.
And then we want another folder called Server, which is where all of our server logic is going to be.
And in this case, we have a couple of files we'll need we'll need a main.
We'll need a connection.
We'll need chats.
And we'll call this one chat map.
So client is a single executable file.
Let me clean up all of these really quickly.
All right.
So our client is a single file executable for the chat and our server is the executable for our server,
which will be spread into those four different files we created.
So now let's take a look at our utils file.
And we can start defining some types that we will use throughout the application.
So Utils is going to contain our utilities that we will use throughout our application.
So the first thing we want is we want our standard air.
And now we're going to create a couple of types.
So our first type is going to be our chat air, which is going to be a smart pointer of a box using
an air, and it's going to have a send sync and a static lifetime.
And then we're also going to create a chat result type over a generic T, which is going to give us
a result or a chat air.
So as we use our own air types, we will see that the question mark.
OPERATOR So the question mark.
Operator.
Well automatically be able to convert different air types into a chat air by using the standard libraries
from trait to the type we implemented right here.
So we will use, send and seek.
Excuse me.
We use send and sync bounds to ensure that if a task that is spawned on another thread fails, it will
be able to safely report the failure up to Main.
So hopefully that makes sense.
And if it doesn't, you'll be able to see it a little bit more as we continue our program.
But now that we have something set up in the next lecture, we will begin working on our chats protocol.