anchor.diff:      <<Float:32/float>>;
   encode_type(double,Double) ->
       <<Double:64/float>>;
  -encode_type(boolean,true) ->
  -    <<$T>>;
  -encode_type(boolean,false) ->
  -    <<$F>>;
  -encode_type(array,Arr) when is_tuple(Arr) ->
  -    encode_type(array,tuple_to_list(Arr));
  -encode_type(array,List) when is_list(List) ->
  -    encode_array(List);
   encode_type(date,D) ->
       encode_svarint(D);
   encode_type(byte,B) ->
  
positive.code: encode_channel_type(Other) -> Other.
  
  %% Tagged types
  encode_obj(?raw(Data)) ->
      Data;
  encode_obj(?map(Data)) ->
      [?VARINT_MAP,encode_map(Data)];
  encode_obj(?array(Data)) ->
      [?VARINT_ARRAY,encode_array(Data)];
  encode_obj(?error(Code,Msg)) ->
      [?VARINT_ERROR,encode_type(svarint32,Code),encode_obj(Msg)];
  encode_obj(?bytes(Data)) ->
      [?VARINT_BYTES,encode_type(bytes,Data)];
  encode_obj(?byte(Byte)) ->
      [?BYTE,Byte];
  encode_obj(?uuid(Data)) ->
      [?UUID,encode_type(uuid,Data)];
  encode_obj(?secid(Data)) ->
      [?SECID,encode_type(secid,Data)];
  encode_obj(?time(Data)) ->
      [?VARINT_TIME,encode_type(date,Data)];
  %% exact types
  encode_obj(true) -> [?TRUE];
  encode_obj(false) -> [?FALSE];
  encode_obj(undefined) -> [?NULL];
  encode_obj(null) -> [?NULL];
  encode_obj(nil) -> [?NULL];
  %% inferred types
  encode_obj(Obj) when is_integer(Obj), Obj < 0 ->
      [?SVARINT64,encode_type(svarint64,Obj)];
  encode_obj(Obj) when is_integer(Obj) ->
      [?VARINT64,encode_type(varint64,Obj)];
  encode_obj(Obj) when is_float(Obj) ->
      [?DOUBLE,encode_type(double,Obj)];
  encode_obj(Obj) when is_atom(Obj) ->
      [?VARINT_STRING,encode_type(string,Obj)];
  encode_obj(Obj) when is_binary(Obj) ->
      [?VARINT_STRING,encode_type(string,Obj)];
  encode_obj(Obj) when is_list(Obj) ->
      [?VARINT_ARRAY,encode_type(array,Obj)];
  encode_obj(Obj) when is_tuple(Obj) ->
      [?VARINT_ARRAY,encode_type(array,Obj)].
  
  %% Encodes a given value as the specified type
  %% Note: This does NOT prefix with a type specifier, it's up to the caller
  
negative.code: encode_type(string,String) when is_binary(String)->
      [encode_varint(size(String)),String].
  
  encode_array(Vsn, Data) ->
      encode_array(Vsn, Data, 0, []).
  
  encode_array(_Vsn, [], Sz, Acc) ->
      {Sz, lists:reverse(Acc)};
  encode_array(Vsn, [Item | Items], Sz, Acc) ->
      encode_array(Vsn, Items, Sz + 1,[encode_obj(Vsn, Item) | Acc]).
  
  encode_map(Vsn, Data) ->
      encode_map(Vsn, Data, 0, []).
  
  encode_map(_Vsn, [], Sz, Acc) ->
      {Sz, Acc};
  encode_map(Vsn, [{K, V} | Tail], Sz, Acc) ->
      encode_map(Vsn,
                 Tail,
                 Sz + 1,
                 [encode_obj(Vsn, K), encode_obj(Vsn, V) | Acc]).
  
  encode_uuid(Bin) when is_binary(Bin) ->
      Bin;
  