copy + paste of Apache thrift erlang lib. Mirrored here so it can be used for rebar/mix etc