This trait indicates that a struct represents a single row in a database table.
This must be implemented to use associations.
Additionally, implementing this trait allows you to pass your struct to
update(&your_struct) is equivalent to
This trait is usually implemented on a reference to a struct, not on the struct itself. It can be derived.
The type of this struct’s identifier.
For single-field primary keys, this is typically
&'a i32, or
For composite primary keys, this is typically
(&'a i32, &'a i32)
(&'a String, &'a String), etc.
Returns the identifier for this record.
self by value, not reference.
This is because composite primary keys
are typically stored as multiple fields.
We could not return
&(String, String) if each string is a separate field.
Because of Rust’s rules about specifying lifetimes,
this means that
Identifiable is usually implemented on references
so that we have a lifetime to use for