The message function is where the main logic of our program happens. await method.Īfter that, the impl EventHandler for Handler tells the compiler, “My struct called Handler is going to look like an EventHandler.” Inside the struct are two functions: message and ready. In the next block, we use the # macro to tell the compiler that the struct below implements that trait like allowing us to use the async keyword with our functions and the. This doesn’t do much because all it does is declare the struct without any fields. In this part of the program, I declare struct Handler. I’ll add the code and then afterwards I’ll walk through how it works.
Since this is a small program, I will only need to add code to the main.rs file.