00:00:04.246 --> 00:00:05.126 Yeah. Yep.
00:00:06.856 --> 00:00:07.926 One second.
00:00:11.386 --> 00:00:14.626 In the different commands that are available and how it goes.
00:00:16.336 --> 00:00:17.006 Rights.
00:00:19.566 --> 00:00:23.771 Great. So Maestro is the connect project management tool, project
00:00:23.771 --> 00:00:27.657 management in the development sense, not in the you you have
00:00:27.657 --> 00:00:29.696 to go another meeting now since?
00:00:32.176 --> 00:00:35.724 So the current iteration is under the Maestro 5 command
00:00:35.724 --> 00:00:39.462 there. Yes, there is also A1 without the five suffix. That
00:00:39.462 --> 00:00:43.517 one is for the connected version four. We just didn't add a new
00:00:43.517 --> 00:00:47.318 suffix to that to maintain compatibility. So in the current
00:00:47.318 --> 00:00:50.486 connect version five you will be using Maestro 5.
00:00:52.786 --> 00:00:54.696 If you run by your five directly, you'll get a list of
00:00:54.696 --> 00:00:55.286 all the commands.
00:00:56.226 --> 00:01:00.102 Or I should say the top of the commands, so Maestro 5 is built
00:01:00.102 --> 00:01:02.686 outs with a general subcommand structure.
00:01:03.816 --> 00:01:06.903 Before we go into that though, if you want to get shell
00:01:06.903 --> 00:01:10.210 completion, you do ministro 5 generate and then the name of
00:01:10.210 --> 00:01:10.816 your shell.
00:01:13.366 --> 00:01:14.646 Look here it will support.
00:01:13.716 --> 00:01:16.448 If you mean to be sharing your screen, you're not sharing the
00:01:16.448 --> 00:01:16.756 screen.
00:01:17.426 --> 00:01:18.396 Well, I'm moron.
00:01:19.736 --> 00:01:20.856 Keep that part in there according.
00:01:23.086 --> 00:01:27.846 OK. We have Mr. 5, Patty, yadda yadda repeat everything I said.
00:01:31.056 --> 00:01:31.746 So then.
00:01:33.386 --> 00:01:36.516 The Maestro 5 generate commands is what's used to generate shell
00:01:36.516 --> 00:01:39.598 completions exactly. We have to put these is going to depend on
00:01:39.598 --> 00:01:42.536 your shell, so I'll leave that as an exercise to the reader.
00:01:44.336 --> 00:01:47.397 But so for example, in my case I use the fish shell. So if I just
00:01:47.397 --> 00:01:49.901 run that the generate completions and you can see it,
00:01:49.901 --> 00:01:52.266 I can just keep tabbing my way through everything.
00:01:55.656 --> 00:01:59.034 The actual support for what each shell can give you from
00:01:59.034 --> 00:02:02.887 tabulation will vary, so you may not be able to expect this full
00:02:02.887 --> 00:02:03.776 level of stuff.
00:02:04.416 --> 00:02:08.056 But I highly recommend getting that completion installed.
00:02:10.586 --> 00:02:13.600 So just going through the commands we have available,
00:02:13.600 --> 00:02:17.117 project the projects in a class of commands currently only has
00:02:17.117 --> 00:02:18.066 the new commands.
00:02:19.336 --> 00:02:20.526 You can see an example of it here.
00:02:21.266 --> 00:02:26.081 So explaining this entire commands, last you project 5
00:02:26.081 --> 00:02:26.956 obviously.
00:02:27.696 --> 00:02:31.156 Project commands we want a new project. We want it to use the
00:02:31.156 --> 00:02:34.615 core branch feature cleanup. This is not required by default,
00:02:34.615 --> 00:02:38.075 it will just use whatever the default branch currently is for
00:02:38.075 --> 00:02:38.856 the core repo.
00:02:40.496 --> 00:02:44.101 We can instructed on where we want it to pull templates from.
00:02:44.101 --> 00:02:47.591 Also not required, you'll just defaults to cloning down the
00:02:47.591 --> 00:02:51.196 latest instance of the templates or connect or sorry clarity,
00:02:51.196 --> 00:02:52.766 Connect templates, rebuild.
00:02:53.876 --> 00:02:57.418 There is also a templates branch option that you can use if you
00:02:57.418 --> 00:03:01.015 don't want to clone down first, but these two options are really
00:03:01.015 --> 00:03:04.446 only there for local development of the templates themselves.
00:03:05.726 --> 00:03:08.523 Normally you would not need them, but I'll keep on here for
00:03:08.523 --> 00:03:09.036 the moment.
00:03:12.746 --> 00:03:16.028 The width series of commands allows you to add new
00:03:16.028 --> 00:03:20.146 connectors, or I should say add existing connectors and then if
00:03:20.146 --> 00:03:23.556 we wanted a brand new connector we just do with new.
00:03:24.196 --> 00:03:27.093 And then they whatever we want. So let's say we're going to work
00:03:27.093 --> 00:03:27.316 with.
00:03:28.246 --> 00:03:28.926 Bright Pearl.
00:03:30.156 --> 00:03:32.429 You just do that and it'll template out new connector for
00:03:32.429 --> 00:03:32.546 us.
00:03:34.206 --> 00:03:36.346 Then we can specify the out directory, Yep.
00:03:34.906 --> 00:03:35.696 How do you?
00:03:36.456 --> 00:03:38.546 How do you add more connectors to this project?
00:03:40.086 --> 00:03:41.066 I mean after you start.
00:03:40.186 --> 00:03:41.666 Are they comma separated or?
00:03:42.536 --> 00:03:43.006 Ohh.
00:03:44.346 --> 00:03:45.196 You just keep adding more.
00:03:44.696 --> 00:03:44.996 OK.
00:03:46.076 --> 00:03:47.076 Let's say once.
00:03:48.266 --> 00:03:49.716 What something I gotta break it?
00:03:52.806 --> 00:03:53.786 That's a good example.
00:03:55.796 --> 00:03:58.825 Ohh God, I'll stick with one for the moment since this is the one
00:03:58.825 --> 00:04:01.716 I know already is going to work and just build out-of-the-box.
00:04:03.116 --> 00:04:05.386 So one new one we can just use with new.
00:04:06.046 --> 00:04:08.492 We can set the object to that we want and then we set the project
00:04:08.492 --> 00:04:09.456 name as the last argument.
00:04:11.766 --> 00:04:15.088 So overall you would not actually need more or you would
00:04:15.088 --> 00:04:18.527 not actually need these two right here. You could get away
00:04:18.527 --> 00:04:21.266 with just the other three or four technically.
00:04:22.846 --> 00:04:25.506 But I'll just run this and we can see it work.
00:04:28.156 --> 00:04:28.646 Ohh whoops.
00:04:30.276 --> 00:04:32.945 But you know, you choose to do that right after you merge the
00:04:32.945 --> 00:04:33.246 branch.
00:04:34.416 --> 00:04:34.676 Oops.
00:04:37.256 --> 00:04:41.408 Good enough. Everything out here. It will not let you make a
00:04:41.408 --> 00:04:43.926 project in a non empty directory so.
00:04:44.776 --> 00:04:46.186 Just as a safety precaution.
00:04:47.666 --> 00:04:49.036 So we'll come down core.
00:04:49.826 --> 00:04:51.876 Your connectors create your solution file.
00:04:55.556 --> 00:04:56.426 Just go open this up.
00:04:59.526 --> 00:05:01.993 Now we have our existing Salesforce connector and our new
00:05:01.993 --> 00:05:02.886 Bright Pro connector.
00:05:05.066 --> 00:05:08.882 I'll add it in here nicely and if we were to look at rider, it
00:05:08.882 --> 00:05:12.396 will also automatically generate your directory mappings.
00:05:13.206 --> 00:05:16.244 Although right now by obviously doesn't actually have a git repo
00:05:16.244 --> 00:05:17.226 since it's brand new.
00:05:22.116 --> 00:05:25.329 And yeah, it scaffolds out everything else. These specifics
00:05:25.329 --> 00:05:28.596 of the templates themselves are probably best off to another
00:05:28.596 --> 00:05:31.006 video S we'll skip over that for the moment.
00:05:33.606 --> 00:05:36.908 So the rest of the commands we have available first the ECB
00:05:36.908 --> 00:05:40.541 user commands the most important of which probably is equal to be
00:05:40.541 --> 00:05:40.926 delete.
00:05:41.676 --> 00:05:44.897 So let's say that I watch it runs again. It'll obviously
00:05:44.897 --> 00:05:48.288 allow the error because there's already an easy DB database
00:05:48.288 --> 00:05:50.436 created for us to go and delete that.
00:05:54.076 --> 00:05:57.402 Now you could be delete can be called with either just the
00:05:57.402 --> 00:05:59.826 suffix or the entire ETB under score name.
00:06:02.326 --> 00:06:03.556 Ask you to reconfirm it.
00:06:04.596 --> 00:06:07.303 And I'll drop it for you. So that's point I could be then
00:06:07.303 --> 00:06:10.056 obviously, if I got rid of that directory, run this again.
00:06:14.476 --> 00:06:18.301 Now the other commands available right now are list which will
00:06:18.301 --> 00:06:22.066 just give you a list of all of the equity databases you have.
00:06:22.786 --> 00:06:26.355 Pulling from both Peachy Pass and the database itself. So
00:06:26.355 --> 00:06:30.233 let's say that somebody deleted both the database and my entry
00:06:30.233 --> 00:06:34.048 PG pass. It will still go out and find that there's an A user
00:06:34.048 --> 00:06:37.987 matching the correct form for an ekb database and tell you it's
00:06:37.987 --> 00:06:41.556 there. Just we'll tell you that these things don't exist.
00:06:42.696 --> 00:06:46.069 Similarly, if there's only a PG pass entry but no database or
00:06:46.069 --> 00:06:49.224 user, it'll tell you that database, et cetera, et cetera,
00:06:49.224 --> 00:06:52.596 et cetera. You can see here it will censor passwords and such
00:06:52.596 --> 00:06:53.956 from the PG pass entries.
00:06:54.796 --> 00:06:57.795 The reason it did not sense of these before because these are
00:06:57.795 --> 00:07:00.795 obviously destructive commands that are happening, so it just
00:07:00.795 --> 00:07:02.246 doesn't bother censoring them.
00:07:03.826 --> 00:07:06.589 Like after this command runs, this password is no longer valid
00:07:06.589 --> 00:07:06.896 anyway.
00:07:09.166 --> 00:07:11.604 So that's the list command. I don't believe there are any
00:07:11.604 --> 00:07:13.789 other options. I guess technically there's the show
00:07:13.789 --> 00:07:15.596 passwords that you can use if you want to.
00:07:18.916 --> 00:07:21.516 And finally, there is the new command in there.
00:07:22.936 --> 00:07:24.966 So that I could use.
00:07:25.826 --> 00:07:26.046 Oops.
00:07:28.146 --> 00:07:31.482 So let's say that I had just cloned down M test rather than
00:07:31.482 --> 00:07:34.707 creating it fresh. So for example, let's delete this one.
00:07:34.707 --> 00:07:35.986 Actually I delete that.
00:07:36.986 --> 00:07:39.106 I just create a new one. Boom, they created it.
00:07:40.996 --> 00:07:43.486 Actually just show up my sleeve.
00:07:44.416 --> 00:07:45.206 Delete that.
00:07:49.296 --> 00:07:51.246 Obviously there's no database for right now.
00:07:53.866 --> 00:07:54.816 And boom, every day this.
00:08:06.526 --> 00:08:08.036 So that's the new command.
00:08:09.716 --> 00:08:12.735 There will be some additions to that command in the future, and
00:08:12.735 --> 00:08:15.706 possibly it may be wrapped in another commands, but that's the
00:08:15.706 --> 00:08:18.536 least the most basic command for creating new EDB database.
00:08:21.486 --> 00:08:23.496 So then other commands we have available.
00:08:24.266 --> 00:08:27.456 Uh config, we will go over in just a minute or two.
00:08:28.406 --> 00:08:31.204 There is a new set of app settings commands which are not
00:08:31.204 --> 00:08:33.326 yet available as at the time of this video.
00:08:34.206 --> 00:08:37.980 But what they will allow you to do is they will allow you to
00:08:37.980 --> 00:08:41.444 validate your apps things against the schema as well as
00:08:41.444 --> 00:08:44.166 generate a brand new example settings file.
00:08:51.306 --> 00:08:54.355 Yeah. So the rollback an update commands are not yet fully
00:08:54.355 --> 00:08:57.612 implemented. However, they will eventually allow you to update
00:08:57.612 --> 00:09:00.506 the mystery installation just with one or two commands.
00:09:02.626 --> 00:09:05.648 And that's really all the other ones. So we'll help over the
00:09:05.648 --> 00:09:08.719 config. So the Maestro config commands obviously allow you to
00:09:08.719 --> 00:09:10.106 modify the config of myself.
00:09:11.056 --> 00:09:13.837 The important thing to note there, app settings are for
00:09:13.837 --> 00:09:17.016 connect app settings. Config is for maestros own configuration.
00:09:18.836 --> 00:09:23.102 So here first command we could use is just metro config open.
00:09:23.102 --> 00:09:27.299 Let's just opens up whatever text editor you have configured
00:09:27.299 --> 00:09:31.772 on your system for the defaults like installation wide, Mysterio
00:09:31.772 --> 00:09:32.116 file.
00:09:33.456 --> 00:09:36.754 And then you can see in here this is the main config option
00:09:36.754 --> 00:09:40.106 that most people will are the only one that most people set.
00:09:40.816 --> 00:09:43.376 There are others, but most people aren't gonna need.
00:09:45.306 --> 00:09:48.441 So this is just normal environment file. In fact you
00:09:48.441 --> 00:09:51.990 can set whatever environment variables you want in here and
00:09:51.990 --> 00:09:54.356 they'll all be used, not just Mr. ones.
00:09:56.706 --> 00:10:02.268 But the main one unit set is Maestro EDB Uri. This is the
00:10:02.268 --> 00:10:08.118 connection string to be used for getting to the admin or the
00:10:08.118 --> 00:10:10.516 admin connection for EDB.
00:10:11.166 --> 00:10:14.146 So in this case that's just using my own local user.
00:10:15.436 --> 00:10:19.394 And just connecting to my own local database on the Postgres
00:10:19.394 --> 00:10:20.756 like pseudo database.
00:10:22.526 --> 00:10:25.868 Now what you can use in there is dictated by the Postgres rust
00:10:25.868 --> 00:10:26.186 Craig.
00:10:27.026 --> 00:10:29.867 You can find more documentation on exactly what that supports in
00:10:29.867 --> 00:10:30.086 here.
00:10:31.346 --> 00:10:32.156 We find that.
00:10:35.666 --> 00:10:39.175 So it does support either the more normal C# style or this
00:10:39.175 --> 00:10:41.376 one, which I just personally prefer.
00:10:45.316 --> 00:10:48.425 So the contract file this commands does support some other
00:10:48.425 --> 00:10:48.846 options.
00:10:49.556 --> 00:10:52.396 So the way contact works in Maestro, there are three
00:10:52.396 --> 00:10:55.825 separate sets of places that are less technically four separate
00:10:55.825 --> 00:10:58.076 sets of places of conflict can come from.
00:10:59.216 --> 00:11:02.522 There is the global conflict file, which is the default if I
00:11:02.522 --> 00:11:03.606 just do open global.
00:11:04.926 --> 00:11:08.131 There is the local file, so basically any dot unv file in
00:11:08.131 --> 00:11:11.556 the current directory or any parent directory of your current
00:11:11.556 --> 00:11:13.766 directory will be respected by Maestro.
00:11:16.026 --> 00:11:18.777 So I can do this and it will actually just create a new one
00:11:18.777 --> 00:11:19.236 or should?
00:11:20.246 --> 00:11:23.066 And it doesn't know how to open it, just that EMP directly.
00:11:24.746 --> 00:11:25.216 Uh.
00:11:27.006 --> 00:11:30.657 And then the process, so the process one would be like let's
00:11:30.657 --> 00:11:30.896 say.
00:11:32.716 --> 00:11:35.984 I'm running this. We have our QB thing. Let's say I just directly
00:11:35.984 --> 00:11:38.806 set an environment variable for this particular process.
00:11:42.966 --> 00:11:43.696 Equals whatever.
00:11:44.716 --> 00:11:45.646 And actually it's.
00:11:46.506 --> 00:11:48.596 I think it's merging the other one on top of that.
00:11:50.536 --> 00:11:53.206 But just normal old shell stuff and then the last place that
00:11:53.206 --> 00:11:55.395 that can come from is just obviously command line
00:11:55.395 --> 00:11:55.876 parameters.
00:11:57.756 --> 00:12:00.437 So to note, the only stuff that actually goes into those
00:12:00.437 --> 00:12:03.306 environment variables right now are things that you can also
00:12:03.306 --> 00:12:06.175 specify through a command line parameter, and this will tell
00:12:06.175 --> 00:12:08.998 you which environment variable it takes it from, as well as
00:12:08.998 --> 00:12:10.926 what the current value of that would be.
00:12:15.026 --> 00:12:18.518 So then the other commands on the under the config would be
00:12:18.518 --> 00:12:19.216 config list.
00:12:20.026 --> 00:12:22.276 Obviously that just tells you everything that's already set
00:12:22.276 --> 00:12:23.326 and where it's being set at.
00:12:23.976 --> 00:12:25.536 So like if I were to.
00:12:26.726 --> 00:12:29.116 Set this one as well my local thing.
00:12:32.616 --> 00:12:36.197 It's not taking it for some reason. I've logged to fix it
00:12:36.197 --> 00:12:36.876 would seem.
00:12:45.306 --> 00:12:45.556 There.
00:12:46.616 --> 00:12:48.971 So you'll see, it'll tell you exactly where things are being
00:12:48.971 --> 00:12:49.396 taken from.
00:12:50.256 --> 00:12:51.606 And all that good stuff.
00:12:52.926 --> 00:12:54.416 There's also the config set.
00:12:55.526 --> 00:12:57.486 So let me just remove that and real quick.
00:12:58.306 --> 00:12:58.896 Uh.
00:13:02.116 --> 00:13:05.492 So the second man takes Keenan value, so the keys themselves
00:13:05.492 --> 00:13:08.758 are actually validated and it will tell you which ones are
00:13:08.758 --> 00:13:12.245 available. You will see it's not the same as what the shell or
00:13:12.245 --> 00:13:15.510 sorry what the environment variables themselves are names,
00:13:15.510 --> 00:13:18.776 but that's just that they're a little bit nicer work with.
00:13:20.806 --> 00:13:23.635 So the two main ones are now you could be your either you already
00:13:23.635 --> 00:13:26.292 seen and uses speech. That's just for whether or not you have
00:13:26.292 --> 00:13:28.992 to usable cloning. Again, most people are going to need to use
00:13:28.992 --> 00:13:29.206 that.
00:13:30.426 --> 00:13:33.463 And you can also specify which location you want to set it in.
00:13:33.463 --> 00:13:35.536 Obviously you can't set it in the process.
00:13:39.126 --> 00:13:42.832 Other than that, that's all the contact commands. That's also
00:13:42.832 --> 00:13:44.266 all the measure command.00:00:07.139 --> 00:00:09.979 And that's just on the feature rest branch. I haven't fully
00:00:09.979 --> 00:00:12.914 merged in yet. They'll probably be something that I do when I
00:00:12.914 --> 00:00:14.239 get full CI CD from Maestro.
00:00:15.889 --> 00:00:18.139 And then the 2nd place is in GitLab.
00:00:21.709 --> 00:00:24.674 So some of the connect Maestro project. So I guess actually
00:00:24.674 --> 00:00:25.119 it's the.
00:00:26.159 --> 00:00:27.809 A little the same path for both of them.
00:00:28.529 --> 00:00:28.809 But.
00:00:30.279 --> 00:00:33.449 It's just that ones on GitLab, ones on the disgusting Azure.
00:00:41.779 --> 00:00:43.199 Yeah, that's where the source is.
00:00:42.009 --> 00:00:45.099 Which, by the way, jail, could we get create?
00:00:45.869 --> 00:00:47.619 Repost stuff for GitLab.
00:00:48.379 --> 00:00:50.199 I can't quite tell you're saying there he is.
00:00:50.639 --> 00:00:53.399 Uh, can we get the ability to make repos in GitLab?
00:00:54.049 --> 00:00:57.400 Ohh, I mean you should have the ability. I think I made you an
00:00:57.400 --> 00:00:57.719 admin.
00:00:58.589 --> 00:01:01.499 Ohh we're cause. I tried making a sage 101 and I couldn't.
00:01:03.199 --> 00:01:04.879 Weird one second.
00:01:05.779 --> 00:01:07.809 It always tried to make me make a whole new.
00:01:08.319 --> 00:01:08.959 On the side.
00:01:09.829 --> 00:01:11.479 Uh, yeah.
00:01:09.939 --> 00:01:10.709 Organization.
00:01:12.269 --> 00:01:14.854 That's weird because you should be able to make your own your
00:01:14.854 --> 00:01:15.229 own user.
00:01:15.749 --> 00:01:16.599 They're already there.
00:01:17.669 --> 00:01:17.919 Never.
00:01:18.979 --> 00:01:22.654 Well, I make those fine. Make a sage 101 underneath the connect
00:01:22.654 --> 00:01:22.999 group.
00:01:23.169 --> 00:01:26.698 Ohly probably just have to give you permission on the group
00:01:26.698 --> 00:01:27.639 itself. Hang on.
00:01:27.389 --> 00:01:29.309 Don't have you guys love for your house?
00:01:33.069 --> 00:01:35.832 I just want to note that it would be nice over time to start
00:01:35.832 --> 00:01:37.599 moving connectors and stuff over here.
00:01:38.459 --> 00:01:39.129 Yeah, yeah.
00:01:39.129 --> 00:01:40.309 Certainly would be nice.
00:01:39.179 --> 00:01:42.702 Because like was said 100, I was planning on making a few todos
00:01:42.702 --> 00:01:44.079 kind of as an example of.
00:01:44.769 --> 00:01:48.237 You know, here's what we can do. If we move to GitLab, we can
00:01:48.237 --> 00:01:51.761 actually track. And by the way, everyone look at the fun image
00:01:51.761 --> 00:01:53.159 jail assigned to my user.
00:01:55.739 --> 00:01:56.969 What does this say? I heart what?
00:01:59.769 --> 00:02:01.879 It's perfect.
00:02:02.239 --> 00:02:05.257 That's surprised she doses so quickly. I was thinking of the
00:02:05.257 --> 00:02:07.039 like a slow bird five months later.
00:02:07.549 --> 00:02:08.719 We should make that a shirt.
00:02:18.819 --> 00:02:20.839 Right, so I added you.
00:02:22.029 --> 00:02:23.519 We're just real quick add.
00:02:24.499 --> 00:02:26.159 You also, as long as we're in here.
00:02:32.309 --> 00:02:33.319 Maintainer I guess.
00:02:35.799 --> 00:02:36.119 Better.
00:02:40.659 --> 00:02:41.459 Alright, added.
00:02:44.429 --> 00:02:45.869 I don't know why there are two bands, but.
00:02:47.829 --> 00:02:48.119 Weird.
00:02:52.939 --> 00:02:55.079 Anything else you wanted to see on the code side of it?
00:02:56.259 --> 00:02:59.599 Or should we just like go into the dive of the real code?
00:03:00.299 --> 00:03:01.109 Yeah, let's dive in.
00:03:02.809 --> 00:03:03.329 Alright.
00:03:03.259 --> 00:03:05.009 They have a full rust tutorial.
00:03:05.479 --> 00:03:06.239 Yeah.
00:03:05.799 --> 00:03:07.249 Yeah, that's what that's gonna be.
00:03:06.169 --> 00:03:07.659 You have 13 minutes go.
00:03:09.419 --> 00:03:12.462 OK, I'm going to leave the basics of rest away for the
00:03:12.462 --> 00:03:12.849 moment.
00:03:14.269 --> 00:03:18.072 So cargoes. Hamel, this is the project specification file.
00:03:18.072 --> 00:03:22.198 These are all the dependencies of mystro kinda look like an MPM
00:03:22.198 --> 00:03:23.229 package in here.
00:03:25.789 --> 00:03:30.039 So anyhow, is used for air handling. Clap is.
00:03:31.449 --> 00:03:34.145 Basically, that's what handles all the command line parsing and
00:03:34.145 --> 00:03:36.631 such for us. It generates commandline completions all that
00:03:36.631 --> 00:03:38.569 stuff as we don't have to deal with all that.
00:03:41.199 --> 00:03:44.409 Let's see that envy handles the ENV files get.
00:03:45.299 --> 00:03:46.459 Needs no introduction.
00:03:48.799 --> 00:03:49.879 What was that?
00:03:50.759 --> 00:03:54.975 Ohh yeah, heck is actually just there for handling case
00:03:54.975 --> 00:03:55.879 conversions.
00:03:57.109 --> 00:04:00.019 And I just try to pick out some of the more important ones.
00:04:02.739 --> 00:04:05.692 This thing is used to merge like different parts of the app.
00:04:05.209 --> 00:04:05.629 Fine.
00:04:05.692 --> 00:04:08.549 Things file into one. It's like all your different example
00:04:06.399 --> 00:04:06.859 That when.
00:04:08.549 --> 00:04:11.309 settings jasons get merged into one file by this create.
00:04:15.459 --> 00:04:17.129 Liquid obviously for templating.
00:04:18.549 --> 00:04:21.119 Let's see anything else that's really important.
00:04:21.929 --> 00:04:22.529 There's ants.
00:04:21.929 --> 00:04:23.899 This is basically like CS project.
00:04:24.249 --> 00:04:26.699 Yeah, only much nicer to read.
00:04:30.629 --> 00:04:32.269 Yeah, that's that really.
00:04:33.189 --> 00:04:33.639 Uh.
00:04:36.919 --> 00:04:40.662 Something goes right. Anything else in there? I know why. Oh,
00:04:40.662 --> 00:04:44.163 yeah, this is just because writers still saves it as that
00:04:44.163 --> 00:04:45.189 file type anyway.
00:04:46.499 --> 00:04:50.344 Eventually this will be where the CD lives, but that's not
00:04:50.344 --> 00:04:52.429 fully set up a working just yet.
00:04:54.879 --> 00:04:57.254 So then we can just dive straight into the code.
00:04:57.254 --> 00:04:58.369 Obviously main is main.
00:04:59.449 --> 00:05:03.567 Uh, so we pull in the external, we're just specifying that we
00:05:03.567 --> 00:05:07.752 actually want to use macros from that. So Ross has like a real
00:05:07.752 --> 00:05:11.671 macro system, unlike C#, that just kind of depends on half
00:05:11.671 --> 00:05:15.059 baked source generators and reflection at runtime.
00:05:17.669 --> 00:05:19.219 So for example.
00:05:20.929 --> 00:05:23.759 Actually, I guess I already got rid of. The only other usage I
00:05:23.759 --> 00:05:24.119 have of.
00:05:24.899 --> 00:05:27.009 Like home baked macros but.
00:05:28.769 --> 00:05:29.389 Let's see.
00:05:36.209 --> 00:05:40.109 So here's an example of macros in the wild. So.
00:05:41.059 --> 00:05:43.869 Our rust has a general macro called derive.
00:05:45.319 --> 00:05:48.154 And no, ma'am, you're just going to get into the general Rust
00:05:48.154 --> 00:05:49.389 tutorial for just a second.
00:05:51.079 --> 00:05:55.015 So Rust has two general types of types, or I should say three of
00:05:55.015 --> 00:05:58.890 them. There are structs. Structs can look like this, where they
00:05:58.890 --> 00:06:00.949 have field or they can look like.
00:06:01.819 --> 00:06:06.385 Maybe like this where it's just like unnamed, basically an
00:06:06.385 --> 00:06:07.469 unnamed tuple.
00:06:08.639 --> 00:06:11.149 That you can also have tuples like.
00:06:15.499 --> 00:06:18.410 I guess right here would be a string and and I size and
00:06:18.410 --> 00:06:19.709 another words an integer.
00:06:22.929 --> 00:06:26.067 Yeah, so structs, enums and traits. So if you look here
00:06:26.067 --> 00:06:28.029 there's trait called auto resolve.
00:06:28.789 --> 00:06:31.639 The way that this plays in the mice show is.
00:06:32.899 --> 00:06:36.606 I separate out every set of options into a CLI opt and an
00:06:36.606 --> 00:06:37.309 actual opt.
00:06:38.119 --> 00:06:41.956 So CLI OPS has all the niceties that make it work well with the
00:06:41.956 --> 00:06:45.494 command line and an OPS. It gets resolved into by the auto
00:06:45.494 --> 00:06:48.971 resolve trade and then this is what gets paths. What gets
00:06:48.971 --> 00:06:52.329 passed to the actual rust function that runs the logic.
00:06:53.809 --> 00:06:55.519 Just to separate concerns there.
00:06:57.479 --> 00:07:00.919 So then traits are a bit like interfaces in C#.
00:07:01.689 --> 00:07:06.579 Uh, because rust has no inheritance, just First off.
00:07:07.749 --> 00:07:11.231 So everything is happening through traits. So then this
00:07:11.231 --> 00:07:15.210 right here is just an example. So this trade actually defines a
00:07:15.210 --> 00:07:19.189 or defines two different types, including one type that must be
00:07:19.189 --> 00:07:21.489 like must implement the error trait.
00:07:22.659 --> 00:07:26.204 So this is a little nice feature you may have heard Scarlett and
00:07:26.204 --> 00:07:27.949 I whiney about that heavier.net.
00:07:29.019 --> 00:07:32.385 Called related or polls that exactly what was it related
00:07:32.385 --> 00:07:32.739 types?
00:07:33.789 --> 00:07:37.279 Camera professor right term for this but anyway.
00:07:36.869 --> 00:07:37.709 I think so.
00:07:38.149 --> 00:07:39.639 And then of course, I'll obviously have functions.
00:07:40.279 --> 00:07:44.226 So then we implement the traits. We say that for this implement
00:07:44.226 --> 00:07:44.719 or like.
00:07:45.439 --> 00:07:49.942 When when new projects AI OPS is being used as the implementation
00:07:49.942 --> 00:07:54.308 of our auto resolve, then this type means this. This type means
00:07:54.308 --> 00:07:54.649 this.
00:07:55.849 --> 00:07:58.827 So it's almost like generic type parameter is just much much much
00:07:58.827 --> 00:07:59.459 more powerful.
00:08:00.809 --> 00:08:03.798 Ends obviously with this implementation like it's C#
00:08:03.798 --> 00:08:07.181 style, you can implement it for like different generics and
00:08:07.181 --> 00:08:08.929 such. So like let's say I have.
00:08:11.659 --> 00:08:12.869 It would be like that.
00:08:13.799 --> 00:08:14.679 Thought to make one of these.
00:08:16.089 --> 00:08:20.809 There are so say we have just like a simple 2D points class.
00:08:22.199 --> 00:08:23.879 I can implement auto resolve.
00:08:24.479 --> 00:08:25.539 For points.
00:08:26.759 --> 00:08:30.149 And I could just implement it for like any old type T.
00:08:31.739 --> 00:08:35.778 And then that will be used for any type of points. Or I could
00:08:35.778 --> 00:08:39.360 even just implement it specifically for one particular
00:08:39.360 --> 00:08:41.119 usage of that generic type.
00:08:42.069 --> 00:08:46.202 So now if I were to use points of F32 somewhere else, which
00:08:46.202 --> 00:08:50.679 this is just like the float, so like 42 is float, F64 is double.
00:08:51.579 --> 00:08:53.559 Then this is the implementation that actually be used.
00:08:54.909 --> 00:08:57.909 That's really really handy, but anyway.
00:08:58.929 --> 00:08:59.309 Uh.
00:09:00.599 --> 00:09:04.669 So that's basic overview of traits in a rambling manner.
00:09:06.329 --> 00:09:10.518 Back over to main file for a second. This is our imports. It
00:09:10.518 --> 00:09:12.509 doesn't or it does also have.
00:09:13.209 --> 00:09:14.139 Like I could do.
00:09:14.829 --> 00:09:17.433 Like a wild card import from a particular module. If I wanted
00:09:17.433 --> 00:09:17.559 to.
00:09:18.239 --> 00:09:21.508 It's not typically used, though, so you'll see milsom like you
00:09:21.508 --> 00:09:24.621 import individual items from everything, and then obviously
00:09:24.621 --> 00:09:26.229 it lets you nest those imports.
00:09:29.529 --> 00:09:33.065 Ross has a module structure, so things are not just implicitly
00:09:33.065 --> 00:09:36.769 available simply by being within the same directory and all that.
00:09:38.789 --> 00:09:42.094 Rather like the of each individual module, including
00:09:42.094 --> 00:09:45.960 like the entire program as a whole must add each other module
00:09:45.960 --> 00:09:49.764 into its own tree, like you can see here, I have a get utils
00:09:49.764 --> 00:09:53.319 file if that's its own module to include into this file.
00:09:54.149 --> 00:09:58.360 There's PG pass file. I must include it as a module into here
00:09:58.360 --> 00:09:59.039 and so on.
00:10:00.109 --> 00:10:02.675 And obviously like a folder itself is also a module, so you
00:10:02.675 --> 00:10:04.599 see there's the. There's the folder project.
00:10:05.579 --> 00:10:07.559 Of the side project module.
00:10:11.749 --> 00:10:12.489 So is that.
00:10:15.009 --> 00:10:17.719 I don't think is actually used at the moments we need to get
00:10:17.719 --> 00:10:18.519 rid of that later.
00:10:20.549 --> 00:10:23.160 And then we have here. This is just the root of the entire
00:10:23.160 --> 00:10:24.089 command line options.
00:10:24.879 --> 00:10:27.869 So I just has like whatever command we're gonna run.
00:10:29.189 --> 00:10:31.948 This is just the way this is set up is just because I'm using the
00:10:31.948 --> 00:10:34.331 Subcommand style. I could put other options up here if I
00:10:34.331 --> 00:10:34.749 wanted to.
00:10:35.869 --> 00:10:39.955 But then we have an enum. So first thing with enums and rest
00:10:39.955 --> 00:10:43.706 they are all like they're actually algebraic data types
00:10:43.706 --> 00:10:47.859 rather than the simple integer tags that you've seen in other
00:10:47.859 --> 00:10:48.529 languages.
00:10:49.469 --> 00:10:51.439 At most notably.net.
00:10:52.669 --> 00:10:53.109 So.
00:10:53.929 --> 00:10:56.629 Like they can actually have values inside their tag.
00:10:57.569 --> 00:11:02.048 And then obviously those values are only like only accessible if
00:11:02.048 --> 00:11:03.909 if the enum is of that tag.
00:11:04.539 --> 00:11:07.729 It's like if the value is of type commands, but the value is
00:11:07.729 --> 00:11:10.971 only project, I can't get to this. If it's update I can't get
00:11:10.971 --> 00:11:12.749 to this blah blah blah blah blah.
00:11:15.899 --> 00:11:19.380 So then another instance of derived macro was being used. So
00:11:19.380 --> 00:11:22.691 here I'm deriving subcommands and then these other little
00:11:22.691 --> 00:11:26.115 macro things are tagging this and being interpreted by this
00:11:26.115 --> 00:11:27.599 thing. So if I go to this.
00:11:28.369 --> 00:11:31.942 You see here, there's actually Rust code which is taking the
00:11:31.942 --> 00:11:35.691 tokens of that rust source file and interpreting them. In order
00:11:35.691 --> 00:11:37.449 to do whatever it needs to do.
00:11:39.049 --> 00:11:41.589 And that's just all implemented by clap already for us.
00:11:42.989 --> 00:11:45.855 So then this thing is just like something that's interpreted by
00:11:45.855 --> 00:11:45.989 it.
00:11:47.499 --> 00:11:50.395 I believe the way CLAP works is that these are all functions
00:11:50.395 --> 00:11:53.480 which get called on the command itself, so you can pass in other
00:11:53.480 --> 00:11:55.569 arbitrary arguments or something like that.
00:11:57.439 --> 00:12:01.373 Yeah, this right here is just denoting that then inside
00:12:01.373 --> 00:12:05.799 project commands this also has more slow commands inside of it
00:12:05.799 --> 00:12:10.014 that gives us that nice tree structure that you saw before,
00:12:10.014 --> 00:12:14.299 like projects. New, et cetera would be the commands project.
00:12:15.309 --> 00:12:15.769 New.
00:12:16.629 --> 00:12:18.759 And then we have all the options that are available for linear.
00:12:23.989 --> 00:12:27.665 It's going down here. I just briefly go over this part, so
00:12:27.665 --> 00:12:31.465 load contract. This is just loading all of the different EMB
00:12:31.465 --> 00:12:31.839 files.
00:12:32.869 --> 00:12:36.057 I don't really need to go over that too much, is just loading
00:12:36.057 --> 00:12:37.189 environment variables.
00:12:38.609 --> 00:12:39.629 In the main.
00:12:40.359 --> 00:12:43.686 And this is just obviously making sure that we don't run
00:12:43.686 --> 00:12:44.679 this as an admin.
00:12:47.419 --> 00:12:48.549 Well the config files.
00:12:50.409 --> 00:12:53.158 I guess small thing to measure will adapt to the name of its
00:12:53.158 --> 00:12:55.726 current binary. So like if you rename the binary, that's
00:12:55.726 --> 00:12:57.439 something else, it'll just take that.
00:12:59.009 --> 00:12:59.479 Uh.
00:13:01.049 --> 00:13:04.049 And then, yeah, so from there, we just parse the commandlet
00:13:04.049 --> 00:13:04.549 arguments.
00:13:05.229 --> 00:13:07.630 And from there we can just use match which is like a
00:13:07.630 --> 00:13:08.989 turbocharged Switch statement.
00:13:09.899 --> 00:13:12.735 To figure out which one we need to run. So like if we got
00:13:12.735 --> 00:13:15.816 generates and it contains the shell like field inside there we
00:13:15.816 --> 00:13:18.359 just want the generate commands with its arguments.
00:13:20.729 --> 00:13:24.173 Same thing with projects. All that stuff we can obviously nest
00:13:24.173 --> 00:13:27.453 things however we want to do that and then that's where the
00:13:27.453 --> 00:13:30.951 auto resolve stuff comes in. So we take the opts that's come in
00:13:30.951 --> 00:13:34.231 or I should say these CLI OPS that come in, we auto resolve
00:13:34.231 --> 00:13:36.199 them. So just calling auto resolve.
00:13:37.089 --> 00:13:39.459 Here tells it since.
00:13:41.049 --> 00:13:44.561 2nd so since this thing is implemented with a resolved OPS
00:13:44.561 --> 00:13:47.419 type of this then that becomes his return type.
00:13:49.799 --> 00:13:53.170 And like there's no extra stuff that's neat that needs to be
00:13:53.170 --> 00:13:55.049 indicated up here, just knows it.
00:13:56.389 --> 00:13:59.789 The question mark is used for error handling, so it will
00:13:59.789 --> 00:14:03.487 attempt to unwrap an error and if it is not able to unwrap an
00:14:03.487 --> 00:14:07.305 error, it will simply return it from the current function while
00:14:07.305 --> 00:14:11.063 automatically casting into the results like the whatever error
00:14:11.063 --> 00:14:13.449 type we need for that current function.
00:14:14.589 --> 00:14:17.427 I'll get that just second. So obviously we have all of our
00:14:17.427 --> 00:14:18.149 other commands.
00:14:21.909 --> 00:14:24.139 Real quick on the CLI OPS.
00:14:27.199 --> 00:14:27.419 Oops.
00:14:29.219 --> 00:14:30.429 Where is a good example?
00:14:35.429 --> 00:14:38.526 So using example of that so we can specify like we want this
00:14:38.526 --> 00:14:41.724 argument to be a long option. So we have like dash, dash from.
00:14:41.724 --> 00:14:44.923 That's our stuff we want this one to be always required but we
00:14:44.923 --> 00:14:47.969 also allow us to load from this other environment variable.
00:14:49.379 --> 00:14:52.207 Which vaping right there is actually just a constant that's
00:14:52.207 --> 00:14:54.329 being interpreted. So if I were to look for.
00:14:55.609 --> 00:14:57.009 Actually, could you be here?
00:14:58.959 --> 00:15:01.683 So it's just loading that string and then using that to find
00:15:01.683 --> 00:15:04.629 which norm environment variables to load it from it. If it is not
00:15:04.629 --> 00:15:05.969 specified on the command line.
00:15:06.619 --> 00:15:09.169 And that's just like a basic feature of clap itself.
00:15:11.879 --> 00:15:16.358 So I'll just real quick go through the new commands just as
00:15:16.358 --> 00:15:17.179 an example.
00:15:19.149 --> 00:15:19.429 Oops.
00:15:21.269 --> 00:15:21.559 It's.
00:15:27.079 --> 00:15:27.489 There it is.
00:15:28.309 --> 00:15:32.780 So here's the new function, like it could be new function so it
00:15:32.780 --> 00:15:37.182 will return a result. So there's a first major difference from
00:15:37.182 --> 00:15:41.444 coming from C#. We don't throw exceptions, we return results
00:15:41.444 --> 00:15:44.169 which contain either the results like.
00:15:44.829 --> 00:15:46.769 You know OK results or an error result.
00:15:47.889 --> 00:15:51.387 So you can see here at the very end of the function return OK of
00:15:51.387 --> 00:15:54.778 the the empty tuple. Empty tuple is basically like void in C#,
00:15:54.778 --> 00:15:58.223 except that like it actually has a value, you can theoretically
00:15:58.223 --> 00:15:58.869 pass around.
00:15:59.659 --> 00:16:02.728 That's what Resty recall is 0 science type. So like it
00:16:02.728 --> 00:16:06.355 doesn't. It doesn't truly have a presence in memory, but for the
00:16:06.355 --> 00:16:09.815 purposes of types and such, we can pass things around as much
00:16:09.815 --> 00:16:10.429 as we want.
00:16:13.179 --> 00:16:17.729 So like, that's also how you obviously handle errors.
00:16:18.499 --> 00:16:22.930 This thing right here, a panic like you should not use this
00:16:22.930 --> 00:16:24.259 very often at all.
00:16:26.509 --> 00:16:30.162 This is like complete halt. The program absolutely no possible
00:16:30.162 --> 00:16:33.757 way of ever catching this error. The program needs help right
00:16:33.757 --> 00:16:33.989 now.
00:16:35.799 --> 00:16:39.633 And the reason that's doing it here is because like basically
00:16:39.633 --> 00:16:43.034 if we fail to use PG pass without getting into details
00:16:43.034 --> 00:16:46.249 here and indicates a logic error in ministrat self.
00:16:47.239 --> 00:16:49.874 So like, that's just something that needs to be handled
00:16:49.874 --> 00:16:52.604 immediately, no matter what. Something goes wrong, do not
00:16:52.604 --> 00:16:53.969 pass go. Do not collect $200.
00:16:57.789 --> 00:16:59.799 Better example real quick.
00:17:04.599 --> 00:17:07.432 Here. So here's an example of returning an error in the rest.
00:17:07.432 --> 00:17:10.219 So we have this new project error type which defines all the
00:17:10.219 --> 00:17:13.189 possible errors that could come out of the new project commands.
00:17:14.359 --> 00:17:17.746 And then this is another example of deriving stuff. So this is
00:17:17.746 --> 00:17:20.704 just deriving the error trait from standard rest. Just
00:17:20.704 --> 00:17:23.715 basically we don't have to derive it ourselves and so I
00:17:23.715 --> 00:17:26.995 implement it ourselves. Like do all the logic for formatting
00:17:26.995 --> 00:17:30.060 errors and such. This just handles it for us and we just
00:17:30.060 --> 00:17:33.179 put attributes on here to specify how we want it to look.
00:17:35.029 --> 00:17:35.419 Uh.
00:17:37.059 --> 00:17:40.889 That it also fails like converging from particular or
00:17:40.889 --> 00:17:43.159 other particular error types so.
00:17:43.779 --> 00:17:47.373 Basically like if that question mark from before was used on a
00:17:47.373 --> 00:17:50.966 result that the returns as an input output error, it will know
00:17:50.966 --> 00:17:54.104 that it can automatically convert into this tag of the
00:17:54.104 --> 00:17:54.389 enum.
00:17:56.359 --> 00:17:56.629 But.
00:17:57.509 --> 00:17:59.049 Anyway, back to.
00:18:00.169 --> 00:18:01.099 That.
00:18:02.559 --> 00:18:03.279 Going everywhere.
00:18:04.979 --> 00:18:08.339 Yeah, we can hear we generate a new password for the new user.
00:18:09.659 --> 00:18:13.632 We get into equity B, which actually I should have looked at
00:18:13.632 --> 00:18:14.869 auto resolve first.
00:18:15.909 --> 00:18:18.259 Seconds. Where was that at?
00:18:20.729 --> 00:18:21.669 Streets.
00:18:27.839 --> 00:18:28.779 Let's fold it. That's why.
00:18:30.789 --> 00:18:34.692 So in our resolve here, we're just taking the, you know
00:18:34.692 --> 00:18:39.084 current directory at expect is basically also a panic. However
00:18:39.084 --> 00:18:42.569 basically I'm using it here in a case where like.
00:18:43.449 --> 00:18:46.632 Like basically, there's no real way that a program could not
00:18:46.632 --> 00:18:49.659 have its own like direct you that you're running it from,
00:18:49.659 --> 00:18:52.059 like you've got to be running from somewhere.
00:18:52.919 --> 00:18:55.949 At least in any youth case that mice was going to be used in.
00:18:56.809 --> 00:18:59.375 So that's why I have this. Just panicking. If it doesn't find
00:18:59.375 --> 00:18:59.499 it.
00:19:00.819 --> 00:19:02.599 So we get our director that currently running in.
00:19:04.019 --> 00:19:06.629 Or I should say man, there's so much to go over.
00:19:07.669 --> 00:19:11.319 So from is an optional type, so rust does not have middle null
00:19:11.319 --> 00:19:15.085 ability. It has the option type, which is just an enum which has
00:19:15.085 --> 00:19:18.677 either none or some, in which case and contains whatever type
00:19:18.677 --> 00:19:19.199 you have.
00:19:22.269 --> 00:19:26.397 So here we are saying either unwrap that and give me the
00:19:26.397 --> 00:19:29.729 inner value or give me the current directory.
00:19:30.929 --> 00:19:33.509 So that just gives like basic defaulting to.
00:19:34.909 --> 00:19:38.006 Like not require you to pass the front directory and the command
00:19:38.006 --> 00:19:40.675 line like if you're already running it from the project
00:19:40.675 --> 00:19:42.009 folder, they'll just use it.
00:19:43.879 --> 00:19:46.349 So then obviously if a if that path does not exist.
00:19:47.589 --> 00:19:50.109 Then we return an error saying you know missing the folder.
00:19:52.239 --> 00:19:55.299 If that's plus the schema directory underneath it.
00:19:55.969 --> 00:19:58.509 Does not exist. Then we have a different error.
00:20:01.669 --> 00:20:04.139 We take our you can, yeah, EB config file.
00:20:04.849 --> 00:20:07.389 Which really cool thing to note here.
00:20:08.329 --> 00:20:08.799 Uh.
00:20:11.119 --> 00:20:15.741 Like I can just directly have it take a Postgres config type on
00:20:15.741 --> 00:20:16.319 the CLI.
00:20:17.069 --> 00:20:19.679 Because this thing here implements.
00:20:20.869 --> 00:20:22.679 Somewhere. Anyway, let's see.
00:20:24.389 --> 00:20:27.871 I'm not sure exactly where the implementation is, but it
00:20:27.871 --> 00:20:31.413 actually implements parse for like the parsable trait for
00:20:31.413 --> 00:20:31.719 this.
00:20:33.379 --> 00:20:36.772 So the command line or the clap can just automatically use that
00:20:36.772 --> 00:20:40.059 to parse the the entire equity B config. It's almost like the
00:20:40.059 --> 00:20:43.188 connection string, but just automatically parses into here
00:20:43.188 --> 00:20:44.089 and validates it.
00:20:47.899 --> 00:20:50.639 Yeah. So then I can here. So it just takes that connects.
00:20:51.389 --> 00:20:55.742 One annoying little thing about the Postgres crate for Rust is
00:20:55.742 --> 00:20:59.749 that you have to specify which TLS to use manually rather
00:20:59.749 --> 00:21:02.789 rather than being in the connection string.
00:21:03.809 --> 00:21:06.489 For now, just assume no tail, since we're probably gonna be
00:21:06.489 --> 00:21:07.829 connecting to it locally, but.
00:21:10.729 --> 00:21:13.199 Now just more simple handling of like.
00:21:13.929 --> 00:21:17.699 If it doesn't start thinking B yeah, prepended onto the string.
00:21:21.599 --> 00:21:25.008 Let's call it the other. You could be listening commands just
00:21:25.008 --> 00:21:28.581 to see if there already is 1 for that particular thing, and this
00:21:28.581 --> 00:21:31.935 obviously this would find like is there a database? Is there
00:21:31.935 --> 00:21:33.969 user? Are there any PG pass entries?
00:21:35.079 --> 00:21:37.539 And tell you whether there are any of those period.
00:21:38.999 --> 00:21:42.388 And that way this with this thing, it's not just checking to
00:21:42.388 --> 00:21:45.721 see if it's Dave based, like if any artifact of that equity
00:21:45.721 --> 00:21:48.499 exists, it's not going to let you make a new one.
00:21:49.629 --> 00:21:52.604 And you've got a wipe it out completely or don't do it at
00:21:52.604 --> 00:21:52.809 all.
00:21:55.929 --> 00:21:57.859 Yeah, there's so much rust stuff to go over here.
00:22:01.079 --> 00:22:05.198 So basically like if there is an existing so like this is almost
00:22:05.198 --> 00:22:05.769 like the.
00:22:06.729 --> 00:22:09.709 Uh here in C# this would be like saying.
00:22:10.379 --> 00:22:12.169 If existing is.
00:22:15.049 --> 00:22:16.339 I guess you or whatever.
00:22:18.659 --> 00:22:21.586 So basically we were pattern matching that is the sum
00:22:21.586 --> 00:22:24.621 variance of the option containing and then something we
00:22:24.621 --> 00:22:26.789 just go ahead and rename this existing.
00:22:28.039 --> 00:22:30.738 And the reason you said the same name here. So like in Russ, it's
00:22:30.738 --> 00:22:31.719 perfectly valid to this.
00:22:33.779 --> 00:22:37.018 I can do whatever the heck I want. That's not changing this
00:22:37.018 --> 00:22:40.419 value. It is making a brand new value which shadows that other
00:22:40.419 --> 00:22:41.769 value with the same name.
00:22:42.989 --> 00:22:46.596 So right here that's doing the same thing. It is taking the
00:22:46.596 --> 00:22:50.323 type of or the name existing, taking the the current value of
00:22:50.323 --> 00:22:53.389 that from that name, which is currently an option.
00:22:54.229 --> 00:22:58.397 And that it is trying to destructure it and extract the
00:22:58.397 --> 00:23:02.119 value of its sum variance if it is that variance.
00:23:02.869 --> 00:23:06.731 And if so, that it assigns to that value the name existing and
00:23:06.731 --> 00:23:10.655 then from here you can see the highline actually picks that for
00:23:10.655 --> 00:23:10.839 me.
00:23:11.919 --> 00:23:14.481 This existing is no longer used inside this if statement. It's
00:23:14.481 --> 00:23:15.539 this existing that's used.
00:23:17.159 --> 00:23:19.992 I guess maybe a little bit confusing the first time you use
00:23:19.992 --> 00:23:22.637 it, but it's really nice, especially when you deal with
00:23:22.637 --> 00:23:24.809 options like this. So like you don't have to.
00:23:23.799 --> 00:23:25.009 Yeah, my mind is blown right now.
00:23:25.509 --> 00:23:28.275 I can't have to rename this like maybe existing because the
00:23:28.275 --> 00:23:31.272 compiler is going to yell at you if you try to use the same name
00:23:31.272 --> 00:23:31.549 again.
00:23:32.249 --> 00:23:34.319 You can just see how we need it.
00:23:35.169 --> 00:23:35.389 Hmm.
00:23:35.239 --> 00:23:39.090 So, like we could have also written this the other way. Like
00:23:39.090 --> 00:23:43.068 let's say that for some reason it's an error to have it not be
00:23:43.068 --> 00:23:43.699 it's like.
00:23:44.509 --> 00:23:48.078 If existing is none, which also really cool thing here. Just to
00:23:48.078 --> 00:23:51.592 note, you see I don't specify the specify option that's office
00:23:51.592 --> 00:23:55.049 at YouTube type that specify the type arguments for option or
00:23:55.049 --> 00:23:56.109 anything like that.
00:23:57.509 --> 00:23:58.079 Hold on.
00:23:59.899 --> 00:24:02.773 Ohh sorry, that's not the technically the correct way of
00:24:02.773 --> 00:24:03.529 comparing that.
00:24:09.859 --> 00:24:12.275 Or destruction and stuff like that supposed to use the if let
00:24:12.275 --> 00:24:12.509 stuff.
00:24:13.839 --> 00:24:18.735 So yeah, if I wanted to actually return an error or the other way
00:24:18.735 --> 00:24:23.260 around, I could do that and then just say let exist existing
00:24:23.260 --> 00:24:27.489 equal existing dot unwrap, that'll take the value of the
00:24:27.489 --> 00:24:31.940 sum or science or existing and shadow the previous value of
00:24:31.940 --> 00:24:35.649 existing or so the previous location of existing.
00:24:37.159 --> 00:24:41.974 So just to note over that there will be a test, so I hope you
00:24:41.974 --> 00:24:44.459 listen to the entire part fully.
00:24:47.539 --> 00:24:48.889 Yeah. So that's that.
00:24:52.339 --> 00:24:55.280 And then this is auto resolving all like all this thing right
00:24:55.280 --> 00:24:58.268 here is doing is just turning the options into a form that the
00:24:58.268 --> 00:24:59.359 function wants to take.
00:24:59.979 --> 00:25:03.091 So it passes in the. You could be client itself, you could be
00:25:03.091 --> 00:25:06.253 config basically so that we can take this config and modify it
00:25:06.253 --> 00:25:09.315 to now have like the correct database and user in that after
00:25:09.315 --> 00:25:10.269 we've created them.
00:25:11.739 --> 00:25:14.540 It's Africans here, so we have the easy to be apps that were
00:25:14.540 --> 00:25:14.999 passed in.
00:25:19.529 --> 00:25:23.729 So then we generate a new password, we take our ebdb name.
00:25:24.709 --> 00:25:27.319 On equity beast like this is a Postgres connection.
00:25:28.049 --> 00:25:29.419 Or Sacco podcast client I should say.
00:25:30.229 --> 00:25:34.218 We execute some SQL. Unfortunately I can't do like
00:25:34.218 --> 00:25:38.756 parameters queries for this since like obviously we we're
00:25:38.756 --> 00:25:39.929 doing full DDL.
00:25:42.469 --> 00:25:45.331 But normally you would have passed parameterized queries in
00:25:45.331 --> 00:25:45.999 through there.
00:25:47.109 --> 00:25:49.563 It's just in this case, like we already know, name is going to
00:25:49.563 --> 00:25:51.745 conform to a particular standard, so we just don't have
00:25:51.745 --> 00:25:53.109 to bother escaping it or anything.
00:25:54.449 --> 00:25:58.253 With her password. So then we create a database owned by that
00:25:58.253 --> 00:25:58.499 guy.
00:25:59.829 --> 00:26:01.679 Add a new entry to the PG pass stuff.
00:26:02.529 --> 00:26:03.019 Uh.
00:26:04.449 --> 00:26:07.899 One thing to note is that the postcard clients are decided
00:26:07.899 --> 00:26:11.582 postcards create on Windows does not currently seem to support
00:26:11.582 --> 00:26:14.857 Unix sockets, although technically lately Postgres does
00:26:14.857 --> 00:26:18.189 support them windows, so I just have to do some platform
00:26:18.189 --> 00:26:22.048 specific stuff which also this I guess kind of shows how stupidly
00:26:22.048 --> 00:26:25.673 simple that is and rest I just tag like even just the part of
00:26:25.673 --> 00:26:29.299 the switch thing, but that wants to pertain to only Linux and
00:26:29.299 --> 00:26:31.579 then that just only compiles on Linux.
00:26:35.829 --> 00:26:39.254 Because like this thing right here is also then set to only
00:26:39.254 --> 00:26:41.709 work on the. I should say Unix in general.
00:26:47.029 --> 00:26:48.659 So yeah, it was that.
00:26:49.509 --> 00:26:52.002 So we make an RPG pass entry with our username, host name,
00:26:52.002 --> 00:26:53.059 blah blah blah blah blah.
00:26:55.969 --> 00:26:58.479 Not sure why this is erroring because that.
00:26:59.239 --> 00:27:00.489 Should work just fine.
00:27:04.989 --> 00:27:05.429 Weird.
00:27:07.229 --> 00:27:09.059 It's like he doesn't build right now.
00:27:13.659 --> 00:27:16.861 Yeah. Anyway, so then once we've created the user first thing we
00:27:16.861 --> 00:27:18.339 do, we add that PG pass entry.
00:27:19.059 --> 00:27:21.828 Then we take the connection cost, that comp that was passed
00:27:21.828 --> 00:27:24.459 in and just change the database name, user and password.
00:27:25.149 --> 00:27:25.639 Uh.
00:27:28.259 --> 00:27:30.379 They what the heck? Why is it doing empty password?
00:27:34.689 --> 00:27:37.839 Oh yeah, that's right. We clear out the password so.
00:27:38.499 --> 00:27:41.538 And the only thing about the Rust crate for Postgres, it does
00:27:41.538 --> 00:27:44.331 not respect PG pass file at all. So I have my own manual
00:27:44.331 --> 00:27:47.468 implementation of loading that file, which thankfully isn't all
00:27:47.468 --> 00:27:47.909 that bad.
00:27:49.559 --> 00:27:52.847 So that's what this thing was doing. So basically we have
00:27:52.847 --> 00:27:55.229 created a user and database for this ekb.
00:27:56.029 --> 00:27:58.619 We have supposedly added an entry to PG Pass.
00:27:59.409 --> 00:28:03.395 So now if we are not able to use that entry PG pass and something
00:28:03.395 --> 00:28:07.261 is horribly wrong, we have just created something that like the
00:28:07.261 --> 00:28:10.583 user cannot or cannot necessarily get into anymore. We
00:28:10.583 --> 00:28:14.509 just need to get the heck out of here. Tell if something's wrong
00:28:14.509 --> 00:28:15.959 and let them correct it.
00:28:17.279 --> 00:28:19.689 And that would indicate like an actual internal bug in Maestro.
00:28:22.379 --> 00:28:24.009 So let me connect to that new config.
00:28:24.669 --> 00:28:28.114 Get a schema directory which another really nice thing with
00:28:28.114 --> 00:28:31.789 rust. You can already see here. It has a proper type for paths.
00:28:34.439 --> 00:28:34.809 Which?
00:28:35.759 --> 00:28:39.828 Fun fact, there paths could contain new lines and other
00:28:39.828 --> 00:28:41.209 stuff like that so.
00:28:42.629 --> 00:28:45.278 Handling of the string is not necessarily the best way of
00:28:45.278 --> 00:28:46.739 going about it. The way C# does.
00:28:49.179 --> 00:28:50.209 Uh, yeah.
00:28:52.569 --> 00:28:56.831 So here I'm basically. I'm just using Russ own built-in path
00:28:56.831 --> 00:28:58.159 handling libraries.
00:28:59.229 --> 00:29:03.128 Which are much nicer to use. I'd like to see sharp self. That's
00:29:03.128 --> 00:29:03.859 just a pain.
00:29:07.439 --> 00:29:08.099 Yeah.
00:29:08.949 --> 00:29:12.869 That sort of ties in here since path is not truly a string, or
00:29:12.869 --> 00:29:16.416 may rather path may not be a printable string because it
00:29:16.416 --> 00:29:18.719 could have other stuff inside of it.
00:29:19.449 --> 00:29:22.164 Like if harder to try to do this, I think it will give me
00:29:22.164 --> 00:29:23.849 the full error that describes that.
00:29:25.369 --> 00:29:25.889 Yeah, here.
00:29:29.039 --> 00:29:31.689 I think it's another things just keep shilling rust all day.
00:29:32.869 --> 00:29:34.549 The error messages and top notch.
00:29:35.629 --> 00:29:38.599 It's it's actually tell you why I can't do this.
00:29:39.859 --> 00:29:40.199 Hello.
00:29:42.329 --> 00:29:43.999 Like why I had to I what I should do?
00:29:45.609 --> 00:29:48.778 So that's why I have to display here. It's because a path could
00:29:48.778 --> 00:29:51.352 contain stuff that can't actually be printed to the
00:29:51.352 --> 00:29:51.699 screen.
00:29:55.739 --> 00:30:00.845 Yeah, that just like grabs it as the display tray and lets you
00:30:00.845 --> 00:30:02.709 then properly print it.
00:30:05.429 --> 00:30:07.659 So yeah, then we just.
00:30:09.669 --> 00:30:11.229 Well, that's the declaration. Get rid of that.
00:30:14.989 --> 00:30:18.729 As we first we just going to ask him directory we we read it.
00:30:19.889 --> 00:30:22.306 And then obviously we just iterate over it, so if it's not
00:30:22.306 --> 00:30:24.519 a file we don't like, we don't care about that thing.
00:30:25.509 --> 00:30:28.531 If it's extension is not sequel, then obviously we don't care
00:30:28.531 --> 00:30:29.409 about that either.
00:30:30.619 --> 00:30:33.688 Then we just say we're executing it. We read it out and we
00:30:33.688 --> 00:30:35.509 executed over the postcode client.
00:30:37.049 --> 00:30:40.616 Yeah, so this context stuff you've been seeing around here,
00:30:40.616 --> 00:30:43.469 this is from the anyhow crate basically anyhow.
00:30:44.479 --> 00:30:48.721 Gives you a really easy way of just taking like like like. I
00:30:48.721 --> 00:30:52.824 don't want to enumerate the other errors that are possible
00:30:52.824 --> 00:30:55.049 here. I just wanted to use them.
00:30:56.229 --> 00:31:00.193 So like in this case batch execute, if we look at this
00:31:00.193 --> 00:31:04.589 definition, it returns a result including the Postgres error
00:31:04.589 --> 00:31:04.949 type.
00:31:07.129 --> 00:31:09.660 So that's like a completely distinct error type from any
00:31:09.660 --> 00:31:12.103 other creates error type including ours, including the
00:31:12.103 --> 00:31:14.279 standard rust standard library stuff, et cetera.
00:31:16.069 --> 00:31:18.929 So what we can do here is we can use the context extension.
00:31:19.699 --> 00:31:22.989 Which extension methods and rest are just more traits?
00:31:23.619 --> 00:31:26.312 It's like we have the context straight which is implemented
00:31:26.312 --> 00:31:27.479 for any result of the any.
00:31:29.529 --> 00:31:33.655 Then we just call that and we'll return the results of either T
00:31:33.655 --> 00:31:33.849 or.
00:31:34.459 --> 00:31:38.173 Uh, the anyhow error type, which then allows it to like wrap
00:31:38.173 --> 00:31:39.939 whatever other type you want.
00:31:42.409 --> 00:31:45.987 And then when we wrap that, it also adds in an extra little
00:31:45.987 --> 00:31:49.684 basically like a text describing what you were doing when the
00:31:49.684 --> 00:31:50.579 error happened.
00:31:52.049 --> 00:31:54.539 And then, like I said before, this little question mark then?
00:31:55.249 --> 00:31:57.219 Uh, like tries to unwrap it so then.
00:31:58.369 --> 00:32:00.399 Like that would be equivalents to.
00:32:01.379 --> 00:32:02.359 Saying something like this.
00:32:03.079 --> 00:32:04.559 Like what the result you called this?
00:32:05.669 --> 00:32:06.789 If flight OK.
00:32:08.069 --> 00:32:12.287 Results equal res. Then we do whatever we want to with the
00:32:12.287 --> 00:32:12.859 results.
00:32:15.189 --> 00:32:18.069 Otherwise we return error.
00:32:19.829 --> 00:32:22.589 So actually I should say elsif.
00:32:23.899 --> 00:32:24.429 That's.
00:32:26.549 --> 00:32:30.019 Error of ER I should use the match for this. I'm done.
00:32:31.609 --> 00:32:32.359 That's results.
00:32:35.149 --> 00:32:36.309 OK, what's some results?
00:32:36.949 --> 00:32:39.019 We use the result for whatever we need to.
00:32:39.719 --> 00:32:43.871 If we have an error E, then we will instead immediately return
00:32:43.871 --> 00:32:47.891 error with E into. I think is essentially what it's going to
00:32:47.891 --> 00:32:48.089 do.
00:32:48.879 --> 00:32:51.765 So in two is basically like the Super powerful trait that lets
00:32:51.765 --> 00:32:54.606 you convert to things together as long as they have the right
00:32:54.606 --> 00:32:55.339 implementations.
00:32:56.899 --> 00:33:00.582 So you'll see this quite often. You can see I don't have to
00:33:00.582 --> 00:33:03.959 specify a type here, it's just that stupidly powerful.
00:33:04.799 --> 00:33:08.247 Because Russ could defer that. OK, well, I'm. I'm going in
00:33:08.247 --> 00:33:12.045 front error type. OK, so what's the type of error? Well, this is
00:33:12.045 --> 00:33:15.318 actually of an like a generic type, but I know that I'm
00:33:15.318 --> 00:33:19.117 returning it and the return type of this function is this result
00:33:19.117 --> 00:33:19.409 type.
00:33:20.089 --> 00:33:23.488 And this result type only has an error of this type. Therefore I
00:33:23.488 --> 00:33:26.625 must be trying to convert into this type. So can I find the
00:33:26.625 --> 00:33:29.762 implementation of a trade for that type? OK, yes, I'll just
00:33:29.762 --> 00:33:30.599 call that trade.
00:33:33.439 --> 00:33:35.389 This is the craft of advising ATC.
00:33:36.069 --> 00:33:36.439 Yeah.
00:33:37.349 --> 00:33:39.799 It's just so much nicer. See anyway.
00:33:40.729 --> 00:33:43.988 All that stuff is implement or is equivalent to just putting
00:33:43.988 --> 00:33:47.301 the question mark at the end, and that's just a Rust language
00:33:47.301 --> 00:33:48.209 feature nowadays.
00:33:49.849 --> 00:33:50.289 Although.
00:33:51.289 --> 00:33:54.219 Again, just calling out this context thing is from the anyhow
00:33:54.219 --> 00:33:56.299 crate, not from something standard to rest.
00:33:57.609 --> 00:34:01.095 Obviously like the inside and all that pure rust, this thing,
00:34:01.095 --> 00:34:02.219 pure rust, etcetera.
00:34:03.749 --> 00:34:05.849 Yeah, that seems very easy to be new commands.
00:34:08.069 --> 00:34:10.619 Yeah, you can see like the information is pretty simple.
00:34:12.999 --> 00:34:14.409 And then the.
00:34:15.749 --> 00:34:16.389 Where's that?
00:34:16.639 --> 00:34:19.339 And I assume the debugging experience is pretty similar to.
00:34:20.059 --> 00:34:20.969 Doing Inc right?
00:34:22.549 --> 00:34:23.909 Yeah, pretty similar.
00:34:25.469 --> 00:34:30.844 Like basically it just uses like any standard C debugger. So like
00:34:30.844 --> 00:34:36.056 LLDB, GDB, et cetera, which does include remote debugging, just
00:34:31.489 --> 00:34:31.799 OK.
00:34:34.539 --> 00:34:34.769 Yep.
00:34:36.056 --> 00:34:36.789 baked it.
00:34:37.429 --> 00:34:37.759 Yeah.
00:34:37.469 --> 00:34:40.019 Just gotta keep throwing some shade at Microsoft.
00:34:42.849 --> 00:34:43.699 Or is that?
00:34:45.979 --> 00:34:47.319 Where is the new project there are.
00:34:48.409 --> 00:34:51.809 Also has some pretty configurable debugging. So for
00:34:51.809 --> 00:34:55.667 example, one time when I was trying to debug a performance
00:34:55.667 --> 00:34:59.395 issue, it was just a quick command line thing to run and
00:34:59.395 --> 00:35:01.749 I'd have it generate a flame graft.
00:35:02.799 --> 00:35:03.899 Hmm, well.
00:35:03.039 --> 00:35:05.079 Versus having to open up a whole new tool.
00:35:03.479 --> 00:35:04.039 And.
00:35:06.319 --> 00:35:09.654 Are you really? You have to go. That deep is open source. Like
00:35:09.654 --> 00:35:13.149 it's an open standard. Microsoft doesn't control and force you to
00:35:13.149 --> 00:35:15.955 only ever use their Ides. Because remember, the only
00:35:15.955 --> 00:35:18.972 reason jet brains has it is because they had to manually
00:35:18.972 --> 00:35:21.249 implement their own debugger from scratch.
00:35:22.689 --> 00:35:23.059 So.
00:35:23.209 --> 00:35:23.569 Hello.
00:35:24.489 --> 00:35:24.959 Yeah.
00:35:25.019 --> 00:35:25.779 Yeah, yeah.
00:35:26.509 --> 00:35:28.739 At any rate, so then if you're looking here.
00:35:30.099 --> 00:35:34.186 All those thing actually has to do then is it just runs new kedb
00:35:34.186 --> 00:35:36.009 with whatever options it has.
00:35:38.549 --> 00:35:39.539 Then you know there.
00:35:40.509 --> 00:35:41.179 This is.
00:35:41.919 --> 00:35:43.919 Getting a little bit further into rest itself.
00:35:45.269 --> 00:35:45.949 So.
00:35:46.609 --> 00:35:49.689 Rust is not all reference types the way C# is.
00:35:50.489 --> 00:35:53.697 So you have actual value types. I mean really just everything is
00:35:53.697 --> 00:35:56.115 a value type unless it's explicitly made to be a
00:35:56.115 --> 00:35:56.609 reference.
00:35:58.669 --> 00:35:59.239 Which new?
00:36:02.829 --> 00:36:05.129 One second, I'm just going to make a brand new.
00:36:11.629 --> 00:36:14.639 Like a brand new crate to just show this in.
00:36:37.789 --> 00:36:40.859 OK, here's basically the rest 101 section.
00:36:42.419 --> 00:36:45.589 So everything's a value essentially, unless it's
00:36:45.589 --> 00:36:49.276 explicitly made to be a reference. So let let X equal 1.
00:36:49.276 --> 00:36:51.929 That's a value type. Obviously, if I do.
00:36:53.439 --> 00:36:55.489 Let's make our point struct again.
00:36:56.649 --> 00:36:57.119 Uh.
00:37:01.089 --> 00:37:03.179 So we have point checked that's a value.
00:37:09.179 --> 00:37:09.419 Oops.
00:37:10.189 --> 00:37:11.399 Do you precise there?
00:37:15.319 --> 00:37:19.127 Like these aren't implicitly references or any of that crap.
00:37:19.127 --> 00:37:22.935 So like if I now do that P 2 = P and I change P or sorry for
00:37:22.935 --> 00:37:26.369 change P2, it's not going to just implicitly change P.
00:37:27.719 --> 00:37:28.429 Now.
00:37:27.909 --> 00:37:28.099 Hmm.
00:37:28.519 --> 00:37:29.029 Uh.
00:37:31.509 --> 00:37:32.139 Interestingly.
00:37:34.019 --> 00:37:37.497 So I think writers was not like fully loading this as a cargo
00:37:37.497 --> 00:37:40.976 project the moment cause this actually should be an error. Or
00:37:40.976 --> 00:37:43.949 actually it. Whoops, sorry, I guess not technically.
00:37:45.849 --> 00:37:46.429 My.
00:37:47.709 --> 00:37:51.399 So here we are. If I would try to say let P3 equal P no.
00:37:52.109 --> 00:37:53.449 That as an error error.
00:37:54.839 --> 00:37:58.189 Because Rust uses full move semantics.
00:37:58.939 --> 00:38:02.844 So when I did this right here. Yeah, it's modeling it as I
00:38:02.844 --> 00:38:05.359 moved the value out of P and into P2.
00:38:06.999 --> 00:38:09.984 Of course, at runtime, or rather at compile time, it's just going
00:38:09.984 --> 00:38:12.744 to optimize that down to using the same location again, like
00:38:12.744 --> 00:38:15.639 there's no, there's no need to physically move anything around.
00:38:16.529 --> 00:38:19.276 But that doesn't mean that this value here no longer has
00:38:19.276 --> 00:38:19.999 anything in it.
00:38:21.369 --> 00:38:22.049 So.
00:38:21.629 --> 00:38:22.769 As appears empty, right?
00:38:23.539 --> 00:38:24.369 Uh.
00:38:24.609 --> 00:38:28.320 The I wanna we wanna say that like cause emptiness might imply
00:38:28.320 --> 00:38:29.969 something like null ability.
00:38:30.349 --> 00:38:30.679 Sure.
00:38:31.389 --> 00:38:34.239 It's just not any valid state to look at it. Period.
00:38:36.309 --> 00:38:40.399 Now there are two ways that you can get around that here. There
00:38:40.399 --> 00:38:44.041 is copy, so I copy here would just immediately solve the
00:38:44.041 --> 00:38:47.939 issue. So copy means that like you can just like Willy nilly
00:38:47.939 --> 00:38:51.965 copy this thing around as many times as you want. So obviously
00:38:51.965 --> 00:38:55.799 stuff like integers are copy. So like if I want X1 equal X.
00:38:56.629 --> 00:38:58.199 What's X 2 = X?
00:38:59.829 --> 00:39:00.119 What?
00:39:01.329 --> 00:39:03.229 Because that's not the point. That's copy, right?
00:39:03.939 --> 00:39:04.419 Not X.
00:39:04.249 --> 00:39:04.749 Yeah, it's.
00:39:07.069 --> 00:39:09.599 That's weird. I could swear in the Jews were copy.
00:39:12.569 --> 00:39:13.579 Learn something new everyday.
00:39:14.989 --> 00:39:15.889 Yeah.
00:39:16.659 --> 00:39:17.869 So yeah, if you maybe.
00:39:16.879 --> 00:39:21.181 I think uh, it clone and copy were mutually exclusive if I
00:39:21.181 --> 00:39:22.129 recall right.
00:39:22.339 --> 00:39:23.949 No, you can. You can have a box.
00:39:29.919 --> 00:39:31.509 So integer wasn't which one?
00:39:32.339 --> 00:39:36.659 I guess integer isn't copy, which is weird or Hong let me.
00:39:37.449 --> 00:39:38.389 Specify the type.
00:39:41.369 --> 00:39:44.319 Yeah, I guess high size is not copyable.
00:39:45.359 --> 00:39:45.769 Interesting.
00:39:46.979 --> 00:39:47.569 Weird.
00:39:48.199 --> 00:39:51.019 So then the way around that so basically.
00:39:52.379 --> 00:39:56.177 Copy is to be used for like super cheap things like it
00:39:56.177 --> 00:40:00.389 doesn't own any resources. It doesn't. It doesn't own memory
00:40:00.389 --> 00:40:01.839 is another big thing.
00:40:02.729 --> 00:40:06.179 It's just like a piece of like, it's just.
00:40:06.949 --> 00:40:07.509 Values.
00:40:08.429 --> 00:40:12.587 Essentially, basically we'll use it for stack types such as I
00:40:12.587 --> 00:40:12.989 guess.
00:40:13.689 --> 00:40:15.978 Going deeper into the computer science rabbit hole for a
00:40:15.978 --> 00:40:16.259 second.
00:40:17.669 --> 00:40:20.347 These things are here are all just being put onto the stack,
00:40:20.347 --> 00:40:23.069 so when the function runs, it has a stack, and there's also a
00:40:23.069 --> 00:40:23.289 heap.
00:40:24.189 --> 00:40:24.949 Stack.
00:40:25.509 --> 00:40:26.049 Uh.
00:40:28.909 --> 00:40:31.549 I just need to get the full lecture from.
00:40:31.389 --> 00:40:32.029 To be huge.
00:40:32.489 --> 00:40:33.529 College here.
00:40:34.499 --> 00:40:38.734 Yeah, physically stack is stuff. Think of it like a local values.
00:40:38.734 --> 00:40:42.199 So like in C, when you make a reference to something.
00:40:43.589 --> 00:40:46.878 And you have that as a value inside your function, that is,
00:40:46.878 --> 00:40:50.496 that has a reference to it, like the value of the reference is on
00:40:50.496 --> 00:40:53.675 the stack, and then that references something over in the
00:40:51.699 --> 00:40:52.019 Yeah.
00:40:53.675 --> 00:40:53.949 heap.
00:40:55.179 --> 00:40:58.487 So copy is just as the short form to be used only for trivial
00:40:58.487 --> 00:41:01.849 things that you want that you'll be able to keep on the stack.
00:41:02.559 --> 00:41:05.549 Like things where it's not going to cost anything to really copy
00:41:05.549 --> 00:41:08.402 them around. You not gonna break anything the matter how many
00:41:08.402 --> 00:41:11.116 times you copy it so then it allows us to just do our, you
00:41:11.116 --> 00:41:14.061 know, implicit copyright here. I don't have to say anything. It
00:41:14.061 --> 00:41:14.659 just does it.
00:41:15.989 --> 00:41:18.912 Now let's say that we had something bigger, like. Let's
00:41:18.912 --> 00:41:19.539 say we have.
00:41:20.749 --> 00:41:25.839 My lists, which is the vector of like 1234.
00:41:26.529 --> 00:41:30.299 Five, so VEC is basically the list of the rest of land.
00:41:31.699 --> 00:41:32.389 And also I guess.
00:41:33.299 --> 00:41:36.747 Real quick side tension. Here's another example of a macro being
00:41:36.747 --> 00:41:40.089 used. So this is actually some compile time macro that's being
00:41:40.089 --> 00:41:42.529 used. It will match however many expressions.
00:41:43.299 --> 00:41:47.462 And then just like call whatever it needs to create the new
00:41:47.462 --> 00:41:48.919 vector and return it.
00:41:49.799 --> 00:41:52.858 So it'll actually compile down into whatever calls to add into
00:41:52.858 --> 00:41:54.169 the vector at compile time.
00:41:56.339 --> 00:42:01.019 So anyway, though VEC on the other hand is not a.
00:42:03.259 --> 00:42:06.256 Like it's not a copyable thing, and here's just another
00:42:06.256 --> 00:42:09.682 shameless rest feature plug you can see I don't have to put the
00:42:09.682 --> 00:42:12.947 typing here, it'll automatically defer it. So for generics I
00:42:12.947 --> 00:42:16.104 could just tell it hey, I don't want to type out this full
00:42:16.104 --> 00:42:18.299 generic type rabbiter you figure it out.
00:42:20.979 --> 00:42:23.869 Anyway, so I can do this just fine.
00:42:25.129 --> 00:42:27.159 But obviously this isn't going to work.
00:42:28.799 --> 00:42:30.849 Because it's already been moved into L1.
00:42:31.969 --> 00:42:34.899 What I can do is I can make this one be a clone.
00:42:36.069 --> 00:42:39.839 So clone is like the full you know.
00:42:41.909 --> 00:42:44.919 Like deep copy, it would be the right way of saying I think.
00:42:44.519 --> 00:42:44.869 Yeah.
00:42:46.019 --> 00:42:50.289 No, it's not necessarily a deep copy. Just to be clear, it it
00:42:50.289 --> 00:42:52.699 depends on the types on semantics.
00:42:53.519 --> 00:42:55.919 So like here.
00:42:58.369 --> 00:43:01.933 I can just actually manually. He's not before. Like I could
00:43:01.933 --> 00:43:05.498 just derive this if I wanted to. It's simple. Basically, if
00:43:05.498 --> 00:43:08.587 everything inside here implements clone, I can just
00:43:08.587 --> 00:43:11.973 derive clone as much as I want because there's already a
00:43:11.973 --> 00:43:13.399 prebuilt deriver for it.
00:43:15.029 --> 00:43:17.886 However, just for the sake of showing it, I can try to
00:43:17.886 --> 00:43:19.029 manually implement it.
00:43:21.389 --> 00:43:23.678 So there's just this clone method. So in here I can do
00:43:23.678 --> 00:43:24.719 whatever the heck I want.
00:43:25.279 --> 00:43:26.109 This is an override.
00:43:28.169 --> 00:43:31.592 Basically, there's no default behavior to it. Override
00:43:31.592 --> 00:43:32.339 technically.
00:43:34.179 --> 00:43:36.748 Default behavior basically just been if I had derived it
00:43:36.748 --> 00:43:37.109 instead.
00:43:37.559 --> 00:43:37.879 Yeah.
00:43:40.619 --> 00:43:42.179 Yeah. So point there is.
00:43:42.949 --> 00:43:45.892 Like you could be doing a deep copy or you might be doing a
00:43:45.892 --> 00:43:49.031 shallow copy and then just like copying some sort of reference.
00:43:49.031 --> 00:43:51.239 It's entirely implementation specific there.
00:43:53.949 --> 00:43:58.332 One nice thing to note, by the way, for the difference between
00:43:58.332 --> 00:44:02.785 copy and clone is that there is never any logic for copies. For
00:44:02.785 --> 00:44:06.821 the most part, you can't override it and make the copy do
00:44:04.089 --> 00:44:04.499 You know.
00:44:06.821 --> 00:44:08.839 weird things to my knowledge.
00:44:14.089 --> 00:44:15.954 Oh, that's interesting. Actually, I think copy
00:44:15.954 --> 00:44:16.629 implements clone.
00:44:18.139 --> 00:44:19.739 I would just create refer to clone.
00:44:20.289 --> 00:44:21.529 Yeah. So I guess.
00:44:20.569 --> 00:44:23.201 Because to my knowledge I thought copy was just a bit wise
00:44:23.201 --> 00:44:24.049 copy almost always.
00:44:24.479 --> 00:44:27.725 Oh no, it is. It looks like there's nothing inside of it.
00:44:27.725 --> 00:44:31.250 It's just that I think whether it it requires clone to also be
00:44:31.250 --> 00:44:33.489 implemented in order to implement copy.
00:44:34.879 --> 00:44:37.859 So actually, I guess technically speaking, I could.