Move struct key_def into an own header.

Move struct key_def into an own header.
Rename key_def methods to follow the coding style.
Rename field_data_type to field_type.
Instead of panicking on key_def initialization
error, throw an exception.