Building module interfaces
Unlike Python, where we can import anything we want from anywhere and at the most our IDE will just give us a syntax highlight, Rust will actively not compile if we try and access data structures that have not explicitly been made public. This gives us an opportunity to really lock down our modules and enforce functionality through an interface.
However, before we get started with this, let's fully explore what functionality we will be locking down. It is good practice to keep modules as isolated as possible. In our stocks
module, the logic should only be around how to handle stocks and nothing else. This might seem a little overkill, but when we think about it, we quickly realize that this module is going to scale when it comes to complexity.
For the demonstrative purposes of this chapter, let's just build the functionality for a stock order. We can either buy or sell a stock. These stock orders come in multiples. It's...