Solution for storing external structs (like Principal) in stable-structures' StableBTreeMap

Cross posting this for future askers.

If you need to store an imported type like the Principal type in the StableBTreeMap, the suggested method of doing so is by wrapping it in a custom tuple struct and using it. Looks like this:

struct StablePrincipal(Principal);

impl Storable for StablePrincipal {
  // implement the storable trait for Principal.

Full discussion here