%% -*- coding: utf-8 -*-
%% Automatically generated, do not edit
%% Generated by gpb_compile version 4.3.1
-module(hex_pb_package).

-export([encode_msg/2, encode_msg/3]).
-export([decode_msg/2, decode_msg/3]).
-export([merge_msgs/3, merge_msgs/4]).
-export([verify_msg/2, verify_msg/3]).
-export([get_msg_defs/0]).
-export([get_msg_names/0]).
-export([get_group_names/0]).
-export([get_msg_or_group_names/0]).
-export([get_enum_names/0]).
-export([find_msg_def/1, fetch_msg_def/1]).
-export([find_enum_def/1, fetch_enum_def/1]).
-export([enum_symbol_by_value/2, enum_value_by_symbol/2]).
-export([enum_symbol_by_value_RetirementReason/1, enum_value_by_symbol_RetirementReason/1]).
-export([get_service_names/0]).
-export([get_service_def/1]).
-export([get_rpc_names/1]).
-export([find_rpc_def/2, fetch_rpc_def/2]).
-export([get_package_name/0]).
-export([gpb_version_as_string/0, gpb_version_as_list/0]).


%% enumerated types
-type 'RetirementReason'() :: 'RETIRED_OTHER' | 'RETIRED_INVALID' | 'RETIRED_SECURITY' | 'RETIRED_DEPRECATED' | 'RETIRED_RENAMED'.
-export_type(['RetirementReason'/0]).

%% message types
-type 'Package'() ::
      #{releases                => ['Release'()],   % = 1
        name                    => iodata(),        % = 2
        repository              => iodata()         % = 3
       }.

-type 'Release'() ::
      #{version                 => iodata(),        % = 1
        checksum                => iodata(),        % = 2
        dependencies            => ['Dependency'()] % = 3
        %% retired              => 'RetirementStatus'() % = 4
       }.

-type 'RetirementStatus'() ::
      #{reason                  => 'RETIRED_OTHER' | 'RETIRED_INVALID' | 'RETIRED_SECURITY' | 'RETIRED_DEPRECATED' | 'RETIRED_RENAMED' | integer() % = 1, enum RetirementReason
        %% message              => iodata()         % = 2
       }.

-type 'Dependency'() ::
      #{package                 => iodata(),        % = 1
        requirement             => iodata()         % = 2
        %% optional             => boolean() | 0 | 1 % = 3
        %% app                  => iodata()         % = 4
        %% repository           => iodata()         % = 5
       }.

-export_type(['Package'/0, 'Release'/0, 'RetirementStatus'/0, 'Dependency'/0]).

-spec encode_msg('Package'() | 'Release'() | 'RetirementStatus'() | 'Dependency'(), atom()) -> binary().
encode_msg(Msg, MsgName) when is_atom(MsgName) ->
    encode_msg(Msg, MsgName, []).

-spec encode_msg('Package'() | 'Release'() | 'RetirementStatus'() | 'Dependency'(), atom(), list()) -> binary().
encode_msg(Msg, MsgName, Opts) ->
    verify_msg(Msg, MsgName, Opts),
    TrUserData = proplists:get_value(user_data, Opts),
    case MsgName of
      'Package' ->
	  e_msg_Package(id(Msg, TrUserData), TrUserData);
      'Release' ->
	  e_msg_Release(id(Msg, TrUserData), TrUserData);
      'RetirementStatus' ->
	  e_msg_RetirementStatus(id(Msg, TrUserData), TrUserData);
      'Dependency' ->
	  e_msg_Dependency(id(Msg, TrUserData), TrUserData)
    end.


e_msg_Package(Msg, TrUserData) ->
    e_msg_Package(Msg, <<>>, TrUserData).


e_msg_Package(#{name := F2, repository := F3} = M, Bin,
	      TrUserData) ->
    B1 = case M of
	   #{releases := F1} ->
	       TrF1 = id(F1, TrUserData),
	       if TrF1 == [] -> Bin;
		  true -> e_field_Package_releases(TrF1, Bin, TrUserData)
	       end;
	   _ -> Bin
	 end,
    B2 = begin
	   TrF2 = id(F2, TrUserData),
	   e_type_string(TrF2, <<B1/binary, 18>>, TrUserData)
	 end,
    begin
      TrF3 = id(F3, TrUserData),
      e_type_string(TrF3, <<B2/binary, 26>>, TrUserData)
    end.

e_msg_Release(Msg, TrUserData) ->
    e_msg_Release(Msg, <<>>, TrUserData).


e_msg_Release(#{version := F1, checksum := F2} = M, Bin,
	      TrUserData) ->
    B1 = begin
	   TrF1 = id(F1, TrUserData),
	   e_type_string(TrF1, <<Bin/binary, 10>>, TrUserData)
	 end,
    B2 = begin
	   TrF2 = id(F2, TrUserData),
	   e_type_bytes(TrF2, <<B1/binary, 18>>, TrUserData)
	 end,
    B3 = case M of
	   #{dependencies := F3} ->
	       TrF3 = id(F3, TrUserData),
	       if TrF3 == [] -> B2;
		  true ->
		      e_field_Release_dependencies(TrF3, B2, TrUserData)
	       end;
	   _ -> B2
	 end,
    case M of
      #{retired := F4} ->
	  begin
	    TrF4 = id(F4, TrUserData),
	    e_mfield_Release_retired(TrF4, <<B3/binary, 34>>,
				     TrUserData)
	  end;
      _ -> B3
    end.

e_msg_RetirementStatus(Msg, TrUserData) ->
    e_msg_RetirementStatus(Msg, <<>>, TrUserData).


e_msg_RetirementStatus(#{reason := F1} = M, Bin,
		       TrUserData) ->
    B1 = begin
	   TrF1 = id(F1, TrUserData),
	   e_enum_RetirementReason(TrF1, <<Bin/binary, 8>>,
				   TrUserData)
	 end,
    case M of
      #{message := F2} ->
	  begin
	    TrF2 = id(F2, TrUserData),
	    e_type_string(TrF2, <<B1/binary, 18>>, TrUserData)
	  end;
      _ -> B1
    end.

e_msg_Dependency(Msg, TrUserData) ->
    e_msg_Dependency(Msg, <<>>, TrUserData).


e_msg_Dependency(#{package := F1, requirement := F2} =
		     M,
		 Bin, TrUserData) ->
    B1 = begin
	   TrF1 = id(F1, TrUserData),
	   e_type_string(TrF1, <<Bin/binary, 10>>, TrUserData)
	 end,
    B2 = begin
	   TrF2 = id(F2, TrUserData),
	   e_type_string(TrF2, <<B1/binary, 18>>, TrUserData)
	 end,
    B3 = case M of
	   #{optional := F3} ->
	       begin
		 TrF3 = id(F3, TrUserData),
		 e_type_bool(TrF3, <<B2/binary, 24>>, TrUserData)
	       end;
	   _ -> B2
	 end,
    B4 = case M of
	   #{app := F4} ->
	       begin
		 TrF4 = id(F4, TrUserData),
		 e_type_string(TrF4, <<B3/binary, 34>>, TrUserData)
	       end;
	   _ -> B3
	 end,
    case M of
      #{repository := F5} ->
	  begin
	    TrF5 = id(F5, TrUserData),
	    e_type_string(TrF5, <<B4/binary, 42>>, TrUserData)
	  end;
      _ -> B4
    end.

e_mfield_Package_releases(Msg, Bin, TrUserData) ->
    SubBin = e_msg_Release(Msg, <<>>, TrUserData),
    Bin2 = e_varint(byte_size(SubBin), Bin),
    <<Bin2/binary, SubBin/binary>>.

e_field_Package_releases([Elem | Rest], Bin,
			 TrUserData) ->
    Bin2 = <<Bin/binary, 10>>,
    Bin3 = e_mfield_Package_releases(id(Elem, TrUserData),
				     Bin2, TrUserData),
    e_field_Package_releases(Rest, Bin3, TrUserData);
e_field_Package_releases([], Bin, _TrUserData) -> Bin.

e_mfield_Release_dependencies(Msg, Bin, TrUserData) ->
    SubBin = e_msg_Dependency(Msg, <<>>, TrUserData),
    Bin2 = e_varint(byte_size(SubBin), Bin),
    <<Bin2/binary, SubBin/binary>>.

e_field_Release_dependencies([Elem | Rest], Bin,
			     TrUserData) ->
    Bin2 = <<Bin/binary, 26>>,
    Bin3 = e_mfield_Release_dependencies(id(Elem,
					    TrUserData),
					 Bin2, TrUserData),
    e_field_Release_dependencies(Rest, Bin3, TrUserData);
e_field_Release_dependencies([], Bin, _TrUserData) ->
    Bin.

e_mfield_Release_retired(Msg, Bin, TrUserData) ->
    SubBin = e_msg_RetirementStatus(Msg, <<>>, TrUserData),
    Bin2 = e_varint(byte_size(SubBin), Bin),
    <<Bin2/binary, SubBin/binary>>.

e_enum_RetirementReason('RETIRED_OTHER', Bin,
			_TrUserData) ->
    <<Bin/binary, 0>>;
e_enum_RetirementReason('RETIRED_INVALID', Bin,
			_TrUserData) ->
    <<Bin/binary, 1>>;
e_enum_RetirementReason('RETIRED_SECURITY', Bin,
			_TrUserData) ->
    <<Bin/binary, 2>>;
e_enum_RetirementReason('RETIRED_DEPRECATED', Bin,
			_TrUserData) ->
    <<Bin/binary, 3>>;
e_enum_RetirementReason('RETIRED_RENAMED', Bin,
			_TrUserData) ->
    <<Bin/binary, 4>>;
e_enum_RetirementReason(V, Bin, _TrUserData) ->
    e_varint(V, Bin).

-compile({nowarn_unused_function,e_type_sint/3}).
e_type_sint(Value, Bin, _TrUserData) when Value >= 0 ->
    e_varint(Value * 2, Bin);
e_type_sint(Value, Bin, _TrUserData) ->
    e_varint(Value * -2 - 1, Bin).

-compile({nowarn_unused_function,e_type_int32/3}).
e_type_int32(Value, Bin, _TrUserData)
    when 0 =< Value, Value =< 127 ->
    <<Bin/binary, Value>>;
e_type_int32(Value, Bin, _TrUserData) ->
    <<N:64/unsigned-native>> = <<Value:64/signed-native>>,
    e_varint(N, Bin).

-compile({nowarn_unused_function,e_type_int64/3}).
e_type_int64(Value, Bin, _TrUserData)
    when 0 =< Value, Value =< 127 ->
    <<Bin/binary, Value>>;
e_type_int64(Value, Bin, _TrUserData) ->
    <<N:64/unsigned-native>> = <<Value:64/signed-native>>,
    e_varint(N, Bin).

-compile({nowarn_unused_function,e_type_bool/3}).
e_type_bool(true, Bin, _TrUserData) ->
    <<Bin/binary, 1>>;
e_type_bool(false, Bin, _TrUserData) ->
    <<Bin/binary, 0>>;
e_type_bool(1, Bin, _TrUserData) -> <<Bin/binary, 1>>;
e_type_bool(0, Bin, _TrUserData) -> <<Bin/binary, 0>>.

-compile({nowarn_unused_function,e_type_string/3}).
e_type_string(S, Bin, _TrUserData) ->
    Utf8 = unicode:characters_to_binary(S),
    Bin2 = e_varint(byte_size(Utf8), Bin),
    <<Bin2/binary, Utf8/binary>>.

-compile({nowarn_unused_function,e_type_bytes/3}).
e_type_bytes(Bytes, Bin, _TrUserData)
    when is_binary(Bytes) ->
    Bin2 = e_varint(byte_size(Bytes), Bin),
    <<Bin2/binary, Bytes/binary>>;
e_type_bytes(Bytes, Bin, _TrUserData)
    when is_list(Bytes) ->
    BytesBin = iolist_to_binary(Bytes),
    Bin2 = e_varint(byte_size(BytesBin), Bin),
    <<Bin2/binary, BytesBin/binary>>.

-compile({nowarn_unused_function,e_type_fixed32/3}).
e_type_fixed32(Value, Bin, _TrUserData) ->
    <<Bin/binary, Value:32/little>>.

-compile({nowarn_unused_function,e_type_sfixed32/3}).
e_type_sfixed32(Value, Bin, _TrUserData) ->
    <<Bin/binary, Value:32/little-signed>>.

-compile({nowarn_unused_function,e_type_fixed64/3}).
e_type_fixed64(Value, Bin, _TrUserData) ->
    <<Bin/binary, Value:64/little>>.

-compile({nowarn_unused_function,e_type_sfixed64/3}).
e_type_sfixed64(Value, Bin, _TrUserData) ->
    <<Bin/binary, Value:64/little-signed>>.

-compile({nowarn_unused_function,e_type_float/3}).
e_type_float(V, Bin, _) when is_number(V) ->
    <<Bin/binary, V:32/little-float>>;
e_type_float(infinity, Bin, _) ->
    <<Bin/binary, 0:16, 128, 127>>;
e_type_float('-infinity', Bin, _) ->
    <<Bin/binary, 0:16, 128, 255>>;
e_type_float(nan, Bin, _) ->
    <<Bin/binary, 0:16, 192, 127>>.

-compile({nowarn_unused_function,e_type_double/3}).
e_type_double(V, Bin, _) when is_number(V) ->
    <<Bin/binary, V:64/little-float>>;
e_type_double(infinity, Bin, _) ->
    <<Bin/binary, 0:48, 240, 127>>;
e_type_double('-infinity', Bin, _) ->
    <<Bin/binary, 0:48, 240, 255>>;
e_type_double(nan, Bin, _) ->
    <<Bin/binary, 0:48, 248, 127>>.

-compile({nowarn_unused_function,e_varint/3}).
e_varint(N, Bin, _TrUserData) -> e_varint(N, Bin).

-compile({nowarn_unused_function,e_varint/2}).
e_varint(N, Bin) when N =< 127 -> <<Bin/binary, N>>;
e_varint(N, Bin) ->
    Bin2 = <<Bin/binary, (N band 127 bor 128)>>,
    e_varint(N bsr 7, Bin2).


decode_msg(Bin, MsgName) when is_binary(Bin) ->
    decode_msg(Bin, MsgName, []).

decode_msg(Bin, MsgName, Opts) when is_binary(Bin) ->
    TrUserData = proplists:get_value(user_data, Opts),
    decode_msg_1_catch(Bin, MsgName, TrUserData).

-ifdef('OTP_RELEASE').
decode_msg_1_catch(Bin, MsgName, TrUserData) ->
    try decode_msg_2_doit(MsgName, Bin, TrUserData)
    catch Class:Reason:StackTrace -> error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}})
    end.
-else.
-ifdef('GPB_PATTERN_STACK').
decode_msg_1_catch(Bin, MsgName, TrUserData) ->
    try decode_msg_2_doit(MsgName, Bin, TrUserData)
    catch Class:Reason:StackTrace -> error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}})
    end.
-else.
decode_msg_1_catch(Bin, MsgName, TrUserData) ->
    try decode_msg_2_doit(MsgName, Bin, TrUserData)
    catch Class:Reason ->
        StackTrace = erlang:get_stacktrace(),
        error({gpb_error,{decoding_failure, {Bin, MsgName, {Class, Reason, StackTrace}}}})
    end.
-endif.

-endif.

decode_msg_2_doit('Package', Bin, TrUserData) ->
    id(d_msg_Package(Bin, TrUserData), TrUserData);
decode_msg_2_doit('Release', Bin, TrUserData) ->
    id(d_msg_Release(Bin, TrUserData), TrUserData);
decode_msg_2_doit('RetirementStatus', Bin,
		  TrUserData) ->
    id(d_msg_RetirementStatus(Bin, TrUserData), TrUserData);
decode_msg_2_doit('Dependency', Bin, TrUserData) ->
    id(d_msg_Dependency(Bin, TrUserData), TrUserData).



d_msg_Package(Bin, TrUserData) ->
    dfp_read_field_def_Package(Bin, 0, 0,
			       id([], TrUserData), id('$undef', TrUserData),
			       id('$undef', TrUserData), TrUserData).

dfp_read_field_def_Package(<<10, Rest/binary>>, Z1, Z2,
			   F@_1, F@_2, F@_3, TrUserData) ->
    d_field_Package_releases(Rest, Z1, Z2, F@_1, F@_2, F@_3,
			     TrUserData);
dfp_read_field_def_Package(<<18, Rest/binary>>, Z1, Z2,
			   F@_1, F@_2, F@_3, TrUserData) ->
    d_field_Package_name(Rest, Z1, Z2, F@_1, F@_2, F@_3,
			 TrUserData);
dfp_read_field_def_Package(<<26, Rest/binary>>, Z1, Z2,
			   F@_1, F@_2, F@_3, TrUserData) ->
    d_field_Package_repository(Rest, Z1, Z2, F@_1, F@_2,
			       F@_3, TrUserData);
dfp_read_field_def_Package(<<>>, 0, 0, R1, F@_2, F@_3,
			   TrUserData) ->
    S1 = #{name => F@_2, repository => F@_3},
    if R1 == '$undef' -> S1;
       true -> S1#{releases => lists_reverse(R1, TrUserData)}
    end;
dfp_read_field_def_Package(Other, Z1, Z2, F@_1, F@_2,
			   F@_3, TrUserData) ->
    dg_read_field_def_Package(Other, Z1, Z2, F@_1, F@_2,
			      F@_3, TrUserData).

dg_read_field_def_Package(<<1:1, X:7, Rest/binary>>, N,
			  Acc, F@_1, F@_2, F@_3, TrUserData)
    when N < 32 - 7 ->
    dg_read_field_def_Package(Rest, N + 7, X bsl N + Acc,
			      F@_1, F@_2, F@_3, TrUserData);
dg_read_field_def_Package(<<0:1, X:7, Rest/binary>>, N,
			  Acc, F@_1, F@_2, F@_3, TrUserData) ->
    Key = X bsl N + Acc,
    case Key of
      10 ->
	  d_field_Package_releases(Rest, 0, 0, F@_1, F@_2, F@_3,
				   TrUserData);
      18 ->
	  d_field_Package_name(Rest, 0, 0, F@_1, F@_2, F@_3,
			       TrUserData);
      26 ->
	  d_field_Package_repository(Rest, 0, 0, F@_1, F@_2, F@_3,
				     TrUserData);
      _ ->
	  case Key band 7 of
	    0 ->
		skip_varint_Package(Rest, 0, 0, F@_1, F@_2, F@_3,
				    TrUserData);
	    1 ->
		skip_64_Package(Rest, 0, 0, F@_1, F@_2, F@_3,
				TrUserData);
	    2 ->
		skip_length_delimited_Package(Rest, 0, 0, F@_1, F@_2,
					      F@_3, TrUserData);
	    3 ->
		skip_group_Package(Rest, Key bsr 3, 0, F@_1, F@_2, F@_3,
				   TrUserData);
	    5 ->
		skip_32_Package(Rest, 0, 0, F@_1, F@_2, F@_3,
				TrUserData)
	  end
    end;
dg_read_field_def_Package(<<>>, 0, 0, R1, F@_2, F@_3,
			  TrUserData) ->
    S1 = #{name => F@_2, repository => F@_3},
    if R1 == '$undef' -> S1;
       true -> S1#{releases => lists_reverse(R1, TrUserData)}
    end.

d_field_Package_releases(<<1:1, X:7, Rest/binary>>, N,
			 Acc, F@_1, F@_2, F@_3, TrUserData)
    when N < 57 ->
    d_field_Package_releases(Rest, N + 7, X bsl N + Acc,
			     F@_1, F@_2, F@_3, TrUserData);
d_field_Package_releases(<<0:1, X:7, Rest/binary>>, N,
			 Acc, Prev, F@_2, F@_3, TrUserData) ->
    {NewFValue, RestF} = begin
			   Len = X bsl N + Acc,
			   <<Bs:Len/binary, Rest2/binary>> = Rest,
			   {id(d_msg_Release(Bs, TrUserData), TrUserData),
			    Rest2}
			 end,
    dfp_read_field_def_Package(RestF, 0, 0,
			       cons(NewFValue, Prev, TrUserData), F@_2, F@_3,
			       TrUserData).

d_field_Package_name(<<1:1, X:7, Rest/binary>>, N, Acc,
		     F@_1, F@_2, F@_3, TrUserData)
    when N < 57 ->
    d_field_Package_name(Rest, N + 7, X bsl N + Acc, F@_1,
			 F@_2, F@_3, TrUserData);
d_field_Package_name(<<0:1, X:7, Rest/binary>>, N, Acc,
		     F@_1, _, F@_3, TrUserData) ->
    {NewFValue, RestF} = begin
			   Len = X bsl N + Acc,
			   <<Bytes:Len/binary, Rest2/binary>> = Rest,
			   {id(binary:copy(Bytes), TrUserData), Rest2}
			 end,
    dfp_read_field_def_Package(RestF, 0, 0, F@_1, NewFValue,
			       F@_3, TrUserData).

d_field_Package_repository(<<1:1, X:7, Rest/binary>>, N,
			   Acc, F@_1, F@_2, F@_3, TrUserData)
    when N < 57 ->
    d_field_Package_repository(Rest, N + 7, X bsl N + Acc,
			       F@_1, F@_2, F@_3, TrUserData);
d_field_Package_repository(<<0:1, X:7, Rest/binary>>, N,
			   Acc, F@_1, F@_2, _, TrUserData) ->
    {NewFValue, RestF} = begin
			   Len = X bsl N + Acc,
			   <<Bytes:Len/binary, Rest2/binary>> = Rest,
			   {id(binary:copy(Bytes), TrUserData), Rest2}
			 end,
    dfp_read_field_def_Package(RestF, 0, 0, F@_1, F@_2,
			       NewFValue, TrUserData).

skip_varint_Package(<<1:1, _:7, Rest/binary>>, Z1, Z2,
		    F@_1, F@_2, F@_3, TrUserData) ->
    skip_varint_Package(Rest, Z1, Z2, F@_1, F@_2, F@_3,
			TrUserData);
skip_varint_Package(<<0:1, _:7, Rest/binary>>, Z1, Z2,
		    F@_1, F@_2, F@_3, TrUserData) ->
    dfp_read_field_def_Package(Rest, Z1, Z2, F@_1, F@_2,
			       F@_3, TrUserData).

skip_length_delimited_Package(<<1:1, X:7, Rest/binary>>,
			      N, Acc, F@_1, F@_2, F@_3, TrUserData)
    when N < 57 ->
    skip_length_delimited_Package(Rest, N + 7,
				  X bsl N + Acc, F@_1, F@_2, F@_3, TrUserData);
skip_length_delimited_Package(<<0:1, X:7, Rest/binary>>,
			      N, Acc, F@_1, F@_2, F@_3, TrUserData) ->
    Length = X bsl N + Acc,
    <<_:Length/binary, Rest2/binary>> = Rest,
    dfp_read_field_def_Package(Rest2, 0, 0, F@_1, F@_2,
			       F@_3, TrUserData).

skip_group_Package(Bin, FNum, Z2, F@_1, F@_2, F@_3,
		   TrUserData) ->
    {_, Rest} = read_group(Bin, FNum),
    dfp_read_field_def_Package(Rest, 0, Z2, F@_1, F@_2,
			       F@_3, TrUserData).

skip_32_Package(<<_:32, Rest/binary>>, Z1, Z2, F@_1,
		F@_2, F@_3, TrUserData) ->
    dfp_read_field_def_Package(Rest, Z1, Z2, F@_1, F@_2,
			       F@_3, TrUserData).

skip_64_Package(<<_:64, Rest/binary>>, Z1, Z2, F@_1,
		F@_2, F@_3, TrUserData) ->
    dfp_read_field_def_Package(Rest, Z1, Z2, F@_1, F@_2,
			       F@_3, TrUserData).

d_msg_Release(Bin, TrUserData) ->
    dfp_read_field_def_Release(Bin, 0, 0,
			       id('$undef', TrUserData),
			       id('$undef', TrUserData), id([], TrUserData),
			       id('$undef', TrUserData), TrUserData).

dfp_read_field_def_Release(<<10, Rest/binary>>, Z1, Z2,
			   F@_1, F@_2, F@_3, F@_4, TrUserData) ->
    d_field_Release_version(Rest, Z1, Z2, F@_1, F@_2, F@_3,
			    F@_4, TrUserData);
dfp_read_field_def_Release(<<18, Rest/binary>>, Z1, Z2,
			   F@_1, F@_2, F@_3, F@_4, TrUserData) ->
    d_field_Release_checksum(Rest, Z1, Z2, F@_1, F@_2, F@_3,
			     F@_4, TrUserData);
dfp_read_field_def_Release(<<26, Rest/binary>>, Z1, Z2,
			   F@_1, F@_2, F@_3, F@_4, TrUserData) ->
    d_field_Release_dependencies(Rest, Z1, Z2, F@_1, F@_2,
				 F@_3, F@_4, TrUserData);
dfp_read_field_def_Release(<<34, Rest/binary>>, Z1, Z2,
			   F@_1, F@_2, F@_3, F@_4, TrUserData) ->
    d_field_Release_retired(Rest, Z1, Z2, F@_1, F@_2, F@_3,
			    F@_4, TrUserData);
dfp_read_field_def_Release(<<>>, 0, 0, F@_1, F@_2, R1,
			   F@_4, TrUserData) ->
    S1 = #{version => F@_1, checksum => F@_2},
    S2 = if R1 == '$undef' -> S1;
	    true ->
		S1#{dependencies => lists_reverse(R1, TrUserData)}
	 end,
    if F@_4 == '$undef' -> S2;
       true -> S2#{retired => F@_4}
    end;
dfp_read_field_def_Release(Other, Z1, Z2, F@_1, F@_2,
			   F@_3, F@_4, TrUserData) ->
    dg_read_field_def_Release(Other, Z1, Z2, F@_1, F@_2,
			      F@_3, F@_4, TrUserData).

dg_read_field_def_Release(<<1:1, X:7, Rest/binary>>, N,
			  Acc, F@_1, F@_2, F@_3, F@_4, TrUserData)
    when N < 32 - 7 ->
    dg_read_field_def_Release(Rest, N + 7, X bsl N + Acc,
			      F@_1, F@_2, F@_3, F@_4, TrUserData);
dg_read_field_def_Release(<<0:1, X:7, Rest/binary>>, N,
			  Acc, F@_1, F@_2, F@_3, F@_4, TrUserData) ->
    Key = X bsl N + Acc,
    case Key of
      10 ->
	  d_field_Release_version(Rest, 0, 0, F@_1, F@_2, F@_3,
				  F@_4, TrUserData);
      18 ->
	  d_field_Release_checksum(Rest, 0, 0, F@_1, F@_2, F@_3,
				   F@_4, TrUserData);
      26 ->
	  d_field_Release_dependencies(Rest, 0, 0, F@_1, F@_2,
				       F@_3, F@_4, TrUserData);
      34 ->
	  d_field_Release_retired(Rest, 0, 0, F@_1, F@_2, F@_3,
				  F@_4, TrUserData);
      _ ->
	  case Key band 7 of
	    0 ->
		skip_varint_Release(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4,
				    TrUserData);
	    1 ->
		skip_64_Release(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4,
				TrUserData);
	    2 ->
		skip_length_delimited_Release(Rest, 0, 0, F@_1, F@_2,
					      F@_3, F@_4, TrUserData);
	    3 ->
		skip_group_Release(Rest, Key bsr 3, 0, F@_1, F@_2, F@_3,
				   F@_4, TrUserData);
	    5 ->
		skip_32_Release(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4,
				TrUserData)
	  end
    end;
dg_read_field_def_Release(<<>>, 0, 0, F@_1, F@_2, R1,
			  F@_4, TrUserData) ->
    S1 = #{version => F@_1, checksum => F@_2},
    S2 = if R1 == '$undef' -> S1;
	    true ->
		S1#{dependencies => lists_reverse(R1, TrUserData)}
	 end,
    if F@_4 == '$undef' -> S2;
       true -> S2#{retired => F@_4}
    end.

d_field_Release_version(<<1:1, X:7, Rest/binary>>, N,
			Acc, F@_1, F@_2, F@_3, F@_4, TrUserData)
    when N < 57 ->
    d_field_Release_version(Rest, N + 7, X bsl N + Acc,
			    F@_1, F@_2, F@_3, F@_4, TrUserData);
d_field_Release_version(<<0:1, X:7, Rest/binary>>, N,
			Acc, _, F@_2, F@_3, F@_4, TrUserData) ->
    {NewFValue, RestF} = begin
			   Len = X bsl N + Acc,
			   <<Bytes:Len/binary, Rest2/binary>> = Rest,
			   {id(binary:copy(Bytes), TrUserData), Rest2}
			 end,
    dfp_read_field_def_Release(RestF, 0, 0, NewFValue, F@_2,
			       F@_3, F@_4, TrUserData).

d_field_Release_checksum(<<1:1, X:7, Rest/binary>>, N,
			 Acc, F@_1, F@_2, F@_3, F@_4, TrUserData)
    when N < 57 ->
    d_field_Release_checksum(Rest, N + 7, X bsl N + Acc,
			     F@_1, F@_2, F@_3, F@_4, TrUserData);
d_field_Release_checksum(<<0:1, X:7, Rest/binary>>, N,
			 Acc, F@_1, _, F@_3, F@_4, TrUserData) ->
    {NewFValue, RestF} = begin
			   Len = X bsl N + Acc,
			   <<Bytes:Len/binary, Rest2/binary>> = Rest,
			   {id(binary:copy(Bytes), TrUserData), Rest2}
			 end,
    dfp_read_field_def_Release(RestF, 0, 0, F@_1, NewFValue,
			       F@_3, F@_4, TrUserData).

d_field_Release_dependencies(<<1:1, X:7, Rest/binary>>,
			     N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData)
    when N < 57 ->
    d_field_Release_dependencies(Rest, N + 7, X bsl N + Acc,
				 F@_1, F@_2, F@_3, F@_4, TrUserData);
d_field_Release_dependencies(<<0:1, X:7, Rest/binary>>,
			     N, Acc, F@_1, F@_2, Prev, F@_4, TrUserData) ->
    {NewFValue, RestF} = begin
			   Len = X bsl N + Acc,
			   <<Bs:Len/binary, Rest2/binary>> = Rest,
			   {id(d_msg_Dependency(Bs, TrUserData), TrUserData),
			    Rest2}
			 end,
    dfp_read_field_def_Release(RestF, 0, 0, F@_1, F@_2,
			       cons(NewFValue, Prev, TrUserData), F@_4,
			       TrUserData).

d_field_Release_retired(<<1:1, X:7, Rest/binary>>, N,
			Acc, F@_1, F@_2, F@_3, F@_4, TrUserData)
    when N < 57 ->
    d_field_Release_retired(Rest, N + 7, X bsl N + Acc,
			    F@_1, F@_2, F@_3, F@_4, TrUserData);
d_field_Release_retired(<<0:1, X:7, Rest/binary>>, N,
			Acc, F@_1, F@_2, F@_3, Prev, TrUserData) ->
    {NewFValue, RestF} = begin
			   Len = X bsl N + Acc,
			   <<Bs:Len/binary, Rest2/binary>> = Rest,
			   {id(d_msg_RetirementStatus(Bs, TrUserData),
			       TrUserData),
			    Rest2}
			 end,
    dfp_read_field_def_Release(RestF, 0, 0, F@_1, F@_2,
			       F@_3,
			       if Prev == '$undef' -> NewFValue;
				  true ->
				      merge_msg_RetirementStatus(Prev,
								 NewFValue,
								 TrUserData)
			       end,
			       TrUserData).

skip_varint_Release(<<1:1, _:7, Rest/binary>>, Z1, Z2,
		    F@_1, F@_2, F@_3, F@_4, TrUserData) ->
    skip_varint_Release(Rest, Z1, Z2, F@_1, F@_2, F@_3,
			F@_4, TrUserData);
skip_varint_Release(<<0:1, _:7, Rest/binary>>, Z1, Z2,
		    F@_1, F@_2, F@_3, F@_4, TrUserData) ->
    dfp_read_field_def_Release(Rest, Z1, Z2, F@_1, F@_2,
			       F@_3, F@_4, TrUserData).

skip_length_delimited_Release(<<1:1, X:7, Rest/binary>>,
			      N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData)
    when N < 57 ->
    skip_length_delimited_Release(Rest, N + 7,
				  X bsl N + Acc, F@_1, F@_2, F@_3, F@_4,
				  TrUserData);
skip_length_delimited_Release(<<0:1, X:7, Rest/binary>>,
			      N, Acc, F@_1, F@_2, F@_3, F@_4, TrUserData) ->
    Length = X bsl N + Acc,
    <<_:Length/binary, Rest2/binary>> = Rest,
    dfp_read_field_def_Release(Rest2, 0, 0, F@_1, F@_2,
			       F@_3, F@_4, TrUserData).

skip_group_Release(Bin, FNum, Z2, F@_1, F@_2, F@_3,
		   F@_4, TrUserData) ->
    {_, Rest} = read_group(Bin, FNum),
    dfp_read_field_def_Release(Rest, 0, Z2, F@_1, F@_2,
			       F@_3, F@_4, TrUserData).

skip_32_Release(<<_:32, Rest/binary>>, Z1, Z2, F@_1,
		F@_2, F@_3, F@_4, TrUserData) ->
    dfp_read_field_def_Release(Rest, Z1, Z2, F@_1, F@_2,
			       F@_3, F@_4, TrUserData).

skip_64_Release(<<_:64, Rest/binary>>, Z1, Z2, F@_1,
		F@_2, F@_3, F@_4, TrUserData) ->
    dfp_read_field_def_Release(Rest, Z1, Z2, F@_1, F@_2,
			       F@_3, F@_4, TrUserData).

d_msg_RetirementStatus(Bin, TrUserData) ->
    dfp_read_field_def_RetirementStatus(Bin, 0, 0,
					id('$undef', TrUserData),
					id('$undef', TrUserData), TrUserData).

dfp_read_field_def_RetirementStatus(<<8, Rest/binary>>,
				    Z1, Z2, F@_1, F@_2, TrUserData) ->
    d_field_RetirementStatus_reason(Rest, Z1, Z2, F@_1,
				    F@_2, TrUserData);
dfp_read_field_def_RetirementStatus(<<18, Rest/binary>>,
				    Z1, Z2, F@_1, F@_2, TrUserData) ->
    d_field_RetirementStatus_message(Rest, Z1, Z2, F@_1,
				     F@_2, TrUserData);
dfp_read_field_def_RetirementStatus(<<>>, 0, 0, F@_1,
				    F@_2, _) ->
    S1 = #{reason => F@_1},
    if F@_2 == '$undef' -> S1;
       true -> S1#{message => F@_2}
    end;
dfp_read_field_def_RetirementStatus(Other, Z1, Z2, F@_1,
				    F@_2, TrUserData) ->
    dg_read_field_def_RetirementStatus(Other, Z1, Z2, F@_1,
				       F@_2, TrUserData).

dg_read_field_def_RetirementStatus(<<1:1, X:7,
				     Rest/binary>>,
				   N, Acc, F@_1, F@_2, TrUserData)
    when N < 32 - 7 ->
    dg_read_field_def_RetirementStatus(Rest, N + 7,
				       X bsl N + Acc, F@_1, F@_2, TrUserData);
dg_read_field_def_RetirementStatus(<<0:1, X:7,
				     Rest/binary>>,
				   N, Acc, F@_1, F@_2, TrUserData) ->
    Key = X bsl N + Acc,
    case Key of
      8 ->
	  d_field_RetirementStatus_reason(Rest, 0, 0, F@_1, F@_2,
					  TrUserData);
      18 ->
	  d_field_RetirementStatus_message(Rest, 0, 0, F@_1, F@_2,
					   TrUserData);
      _ ->
	  case Key band 7 of
	    0 ->
		skip_varint_RetirementStatus(Rest, 0, 0, F@_1, F@_2,
					     TrUserData);
	    1 ->
		skip_64_RetirementStatus(Rest, 0, 0, F@_1, F@_2,
					 TrUserData);
	    2 ->
		skip_length_delimited_RetirementStatus(Rest, 0, 0, F@_1,
						       F@_2, TrUserData);
	    3 ->
		skip_group_RetirementStatus(Rest, Key bsr 3, 0, F@_1,
					    F@_2, TrUserData);
	    5 ->
		skip_32_RetirementStatus(Rest, 0, 0, F@_1, F@_2,
					 TrUserData)
	  end
    end;
dg_read_field_def_RetirementStatus(<<>>, 0, 0, F@_1,
				   F@_2, _) ->
    S1 = #{reason => F@_1},
    if F@_2 == '$undef' -> S1;
       true -> S1#{message => F@_2}
    end.

d_field_RetirementStatus_reason(<<1:1, X:7,
				  Rest/binary>>,
				N, Acc, F@_1, F@_2, TrUserData)
    when N < 57 ->
    d_field_RetirementStatus_reason(Rest, N + 7,
				    X bsl N + Acc, F@_1, F@_2, TrUserData);
d_field_RetirementStatus_reason(<<0:1, X:7,
				  Rest/binary>>,
				N, Acc, _, F@_2, TrUserData) ->
    {NewFValue, RestF} = {id(d_enum_RetirementReason(begin
						       <<Res:32/signed-native>> =
							   <<(X bsl N +
								Acc):32/unsigned-native>>,
						       id(Res, TrUserData)
						     end),
			     TrUserData),
			  Rest},
    dfp_read_field_def_RetirementStatus(RestF, 0, 0,
					NewFValue, F@_2, TrUserData).

d_field_RetirementStatus_message(<<1:1, X:7,
				   Rest/binary>>,
				 N, Acc, F@_1, F@_2, TrUserData)
    when N < 57 ->
    d_field_RetirementStatus_message(Rest, N + 7,
				     X bsl N + Acc, F@_1, F@_2, TrUserData);
d_field_RetirementStatus_message(<<0:1, X:7,
				   Rest/binary>>,
				 N, Acc, F@_1, _, TrUserData) ->
    {NewFValue, RestF} = begin
			   Len = X bsl N + Acc,
			   <<Bytes:Len/binary, Rest2/binary>> = Rest,
			   {id(binary:copy(Bytes), TrUserData), Rest2}
			 end,
    dfp_read_field_def_RetirementStatus(RestF, 0, 0, F@_1,
					NewFValue, TrUserData).

skip_varint_RetirementStatus(<<1:1, _:7, Rest/binary>>,
			     Z1, Z2, F@_1, F@_2, TrUserData) ->
    skip_varint_RetirementStatus(Rest, Z1, Z2, F@_1, F@_2,
				 TrUserData);
skip_varint_RetirementStatus(<<0:1, _:7, Rest/binary>>,
			     Z1, Z2, F@_1, F@_2, TrUserData) ->
    dfp_read_field_def_RetirementStatus(Rest, Z1, Z2, F@_1,
					F@_2, TrUserData).

skip_length_delimited_RetirementStatus(<<1:1, X:7,
					 Rest/binary>>,
				       N, Acc, F@_1, F@_2, TrUserData)
    when N < 57 ->
    skip_length_delimited_RetirementStatus(Rest, N + 7,
					   X bsl N + Acc, F@_1, F@_2,
					   TrUserData);
skip_length_delimited_RetirementStatus(<<0:1, X:7,
					 Rest/binary>>,
				       N, Acc, F@_1, F@_2, TrUserData) ->
    Length = X bsl N + Acc,
    <<_:Length/binary, Rest2/binary>> = Rest,
    dfp_read_field_def_RetirementStatus(Rest2, 0, 0, F@_1,
					F@_2, TrUserData).

skip_group_RetirementStatus(Bin, FNum, Z2, F@_1, F@_2,
			    TrUserData) ->
    {_, Rest} = read_group(Bin, FNum),
    dfp_read_field_def_RetirementStatus(Rest, 0, Z2, F@_1,
					F@_2, TrUserData).

skip_32_RetirementStatus(<<_:32, Rest/binary>>, Z1, Z2,
			 F@_1, F@_2, TrUserData) ->
    dfp_read_field_def_RetirementStatus(Rest, Z1, Z2, F@_1,
					F@_2, TrUserData).

skip_64_RetirementStatus(<<_:64, Rest/binary>>, Z1, Z2,
			 F@_1, F@_2, TrUserData) ->
    dfp_read_field_def_RetirementStatus(Rest, Z1, Z2, F@_1,
					F@_2, TrUserData).

d_msg_Dependency(Bin, TrUserData) ->
    dfp_read_field_def_Dependency(Bin, 0, 0,
				  id('$undef', TrUserData),
				  id('$undef', TrUserData),
				  id('$undef', TrUserData),
				  id('$undef', TrUserData),
				  id('$undef', TrUserData), TrUserData).

dfp_read_field_def_Dependency(<<10, Rest/binary>>, Z1,
			      Z2, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) ->
    d_field_Dependency_package(Rest, Z1, Z2, F@_1, F@_2,
			       F@_3, F@_4, F@_5, TrUserData);
dfp_read_field_def_Dependency(<<18, Rest/binary>>, Z1,
			      Z2, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) ->
    d_field_Dependency_requirement(Rest, Z1, Z2, F@_1, F@_2,
				   F@_3, F@_4, F@_5, TrUserData);
dfp_read_field_def_Dependency(<<24, Rest/binary>>, Z1,
			      Z2, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) ->
    d_field_Dependency_optional(Rest, Z1, Z2, F@_1, F@_2,
				F@_3, F@_4, F@_5, TrUserData);
dfp_read_field_def_Dependency(<<34, Rest/binary>>, Z1,
			      Z2, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) ->
    d_field_Dependency_app(Rest, Z1, Z2, F@_1, F@_2, F@_3,
			   F@_4, F@_5, TrUserData);
dfp_read_field_def_Dependency(<<42, Rest/binary>>, Z1,
			      Z2, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) ->
    d_field_Dependency_repository(Rest, Z1, Z2, F@_1, F@_2,
				  F@_3, F@_4, F@_5, TrUserData);
dfp_read_field_def_Dependency(<<>>, 0, 0, F@_1, F@_2,
			      F@_3, F@_4, F@_5, _) ->
    S1 = #{package => F@_1, requirement => F@_2},
    S2 = if F@_3 == '$undef' -> S1;
	    true -> S1#{optional => F@_3}
	 end,
    S3 = if F@_4 == '$undef' -> S2;
	    true -> S2#{app => F@_4}
	 end,
    if F@_5 == '$undef' -> S3;
       true -> S3#{repository => F@_5}
    end;
dfp_read_field_def_Dependency(Other, Z1, Z2, F@_1, F@_2,
			      F@_3, F@_4, F@_5, TrUserData) ->
    dg_read_field_def_Dependency(Other, Z1, Z2, F@_1, F@_2,
				 F@_3, F@_4, F@_5, TrUserData).

dg_read_field_def_Dependency(<<1:1, X:7, Rest/binary>>,
			     N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData)
    when N < 32 - 7 ->
    dg_read_field_def_Dependency(Rest, N + 7, X bsl N + Acc,
				 F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
dg_read_field_def_Dependency(<<0:1, X:7, Rest/binary>>,
			     N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5,
			     TrUserData) ->
    Key = X bsl N + Acc,
    case Key of
      10 ->
	  d_field_Dependency_package(Rest, 0, 0, F@_1, F@_2, F@_3,
				     F@_4, F@_5, TrUserData);
      18 ->
	  d_field_Dependency_requirement(Rest, 0, 0, F@_1, F@_2,
					 F@_3, F@_4, F@_5, TrUserData);
      24 ->
	  d_field_Dependency_optional(Rest, 0, 0, F@_1, F@_2,
				      F@_3, F@_4, F@_5, TrUserData);
      34 ->
	  d_field_Dependency_app(Rest, 0, 0, F@_1, F@_2, F@_3,
				 F@_4, F@_5, TrUserData);
      42 ->
	  d_field_Dependency_repository(Rest, 0, 0, F@_1, F@_2,
					F@_3, F@_4, F@_5, TrUserData);
      _ ->
	  case Key band 7 of
	    0 ->
		skip_varint_Dependency(Rest, 0, 0, F@_1, F@_2, F@_3,
				       F@_4, F@_5, TrUserData);
	    1 ->
		skip_64_Dependency(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4,
				   F@_5, TrUserData);
	    2 ->
		skip_length_delimited_Dependency(Rest, 0, 0, F@_1, F@_2,
						 F@_3, F@_4, F@_5, TrUserData);
	    3 ->
		skip_group_Dependency(Rest, Key bsr 3, 0, F@_1, F@_2,
				      F@_3, F@_4, F@_5, TrUserData);
	    5 ->
		skip_32_Dependency(Rest, 0, 0, F@_1, F@_2, F@_3, F@_4,
				   F@_5, TrUserData)
	  end
    end;
dg_read_field_def_Dependency(<<>>, 0, 0, F@_1, F@_2,
			     F@_3, F@_4, F@_5, _) ->
    S1 = #{package => F@_1, requirement => F@_2},
    S2 = if F@_3 == '$undef' -> S1;
	    true -> S1#{optional => F@_3}
	 end,
    S3 = if F@_4 == '$undef' -> S2;
	    true -> S2#{app => F@_4}
	 end,
    if F@_5 == '$undef' -> S3;
       true -> S3#{repository => F@_5}
    end.

d_field_Dependency_package(<<1:1, X:7, Rest/binary>>, N,
			   Acc, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData)
    when N < 57 ->
    d_field_Dependency_package(Rest, N + 7, X bsl N + Acc,
			       F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
d_field_Dependency_package(<<0:1, X:7, Rest/binary>>, N,
			   Acc, _, F@_2, F@_3, F@_4, F@_5, TrUserData) ->
    {NewFValue, RestF} = begin
			   Len = X bsl N + Acc,
			   <<Bytes:Len/binary, Rest2/binary>> = Rest,
			   {id(binary:copy(Bytes), TrUserData), Rest2}
			 end,
    dfp_read_field_def_Dependency(RestF, 0, 0, NewFValue,
				  F@_2, F@_3, F@_4, F@_5, TrUserData).

d_field_Dependency_requirement(<<1:1, X:7,
				 Rest/binary>>,
			       N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData)
    when N < 57 ->
    d_field_Dependency_requirement(Rest, N + 7,
				   X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, F@_5,
				   TrUserData);
d_field_Dependency_requirement(<<0:1, X:7,
				 Rest/binary>>,
			       N, Acc, F@_1, _, F@_3, F@_4, F@_5, TrUserData) ->
    {NewFValue, RestF} = begin
			   Len = X bsl N + Acc,
			   <<Bytes:Len/binary, Rest2/binary>> = Rest,
			   {id(binary:copy(Bytes), TrUserData), Rest2}
			 end,
    dfp_read_field_def_Dependency(RestF, 0, 0, F@_1,
				  NewFValue, F@_3, F@_4, F@_5, TrUserData).

d_field_Dependency_optional(<<1:1, X:7, Rest/binary>>,
			    N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData)
    when N < 57 ->
    d_field_Dependency_optional(Rest, N + 7, X bsl N + Acc,
				F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData);
d_field_Dependency_optional(<<0:1, X:7, Rest/binary>>,
			    N, Acc, F@_1, F@_2, _, F@_4, F@_5, TrUserData) ->
    {NewFValue, RestF} = {id(X bsl N + Acc =/= 0,
			     TrUserData),
			  Rest},
    dfp_read_field_def_Dependency(RestF, 0, 0, F@_1, F@_2,
				  NewFValue, F@_4, F@_5, TrUserData).

d_field_Dependency_app(<<1:1, X:7, Rest/binary>>, N,
		       Acc, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData)
    when N < 57 ->
    d_field_Dependency_app(Rest, N + 7, X bsl N + Acc, F@_1,
			   F@_2, F@_3, F@_4, F@_5, TrUserData);
d_field_Dependency_app(<<0:1, X:7, Rest/binary>>, N,
		       Acc, F@_1, F@_2, F@_3, _, F@_5, TrUserData) ->
    {NewFValue, RestF} = begin
			   Len = X bsl N + Acc,
			   <<Bytes:Len/binary, Rest2/binary>> = Rest,
			   {id(binary:copy(Bytes), TrUserData), Rest2}
			 end,
    dfp_read_field_def_Dependency(RestF, 0, 0, F@_1, F@_2,
				  F@_3, NewFValue, F@_5, TrUserData).

d_field_Dependency_repository(<<1:1, X:7, Rest/binary>>,
			      N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData)
    when N < 57 ->
    d_field_Dependency_repository(Rest, N + 7,
				  X bsl N + Acc, F@_1, F@_2, F@_3, F@_4, F@_5,
				  TrUserData);
d_field_Dependency_repository(<<0:1, X:7, Rest/binary>>,
			      N, Acc, F@_1, F@_2, F@_3, F@_4, _, TrUserData) ->
    {NewFValue, RestF} = begin
			   Len = X bsl N + Acc,
			   <<Bytes:Len/binary, Rest2/binary>> = Rest,
			   {id(binary:copy(Bytes), TrUserData), Rest2}
			 end,
    dfp_read_field_def_Dependency(RestF, 0, 0, F@_1, F@_2,
				  F@_3, F@_4, NewFValue, TrUserData).

skip_varint_Dependency(<<1:1, _:7, Rest/binary>>, Z1,
		       Z2, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) ->
    skip_varint_Dependency(Rest, Z1, Z2, F@_1, F@_2, F@_3,
			   F@_4, F@_5, TrUserData);
skip_varint_Dependency(<<0:1, _:7, Rest/binary>>, Z1,
		       Z2, F@_1, F@_2, F@_3, F@_4, F@_5, TrUserData) ->
    dfp_read_field_def_Dependency(Rest, Z1, Z2, F@_1, F@_2,
				  F@_3, F@_4, F@_5, TrUserData).

skip_length_delimited_Dependency(<<1:1, X:7,
				   Rest/binary>>,
				 N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5,
				 TrUserData)
    when N < 57 ->
    skip_length_delimited_Dependency(Rest, N + 7,
				     X bsl N + Acc, F@_1, F@_2, F@_3, F@_4,
				     F@_5, TrUserData);
skip_length_delimited_Dependency(<<0:1, X:7,
				   Rest/binary>>,
				 N, Acc, F@_1, F@_2, F@_3, F@_4, F@_5,
				 TrUserData) ->
    Length = X bsl N + Acc,
    <<_:Length/binary, Rest2/binary>> = Rest,
    dfp_read_field_def_Dependency(Rest2, 0, 0, F@_1, F@_2,
				  F@_3, F@_4, F@_5, TrUserData).

skip_group_Dependency(Bin, FNum, Z2, F@_1, F@_2, F@_3,
		      F@_4, F@_5, TrUserData) ->
    {_, Rest} = read_group(Bin, FNum),
    dfp_read_field_def_Dependency(Rest, 0, Z2, F@_1, F@_2,
				  F@_3, F@_4, F@_5, TrUserData).

skip_32_Dependency(<<_:32, Rest/binary>>, Z1, Z2, F@_1,
		   F@_2, F@_3, F@_4, F@_5, TrUserData) ->
    dfp_read_field_def_Dependency(Rest, Z1, Z2, F@_1, F@_2,
				  F@_3, F@_4, F@_5, TrUserData).

skip_64_Dependency(<<_:64, Rest/binary>>, Z1, Z2, F@_1,
		   F@_2, F@_3, F@_4, F@_5, TrUserData) ->
    dfp_read_field_def_Dependency(Rest, Z1, Z2, F@_1, F@_2,
				  F@_3, F@_4, F@_5, TrUserData).

d_enum_RetirementReason(0) -> 'RETIRED_OTHER';
d_enum_RetirementReason(1) -> 'RETIRED_INVALID';
d_enum_RetirementReason(2) -> 'RETIRED_SECURITY';
d_enum_RetirementReason(3) -> 'RETIRED_DEPRECATED';
d_enum_RetirementReason(4) -> 'RETIRED_RENAMED';
d_enum_RetirementReason(V) -> V.

read_group(Bin, FieldNum) ->
    {NumBytes, EndTagLen} = read_gr_b(Bin, 0, 0, 0, 0, FieldNum),
    <<Group:NumBytes/binary, _:EndTagLen/binary, Rest/binary>> = Bin,
    {Group, Rest}.

%% Like skipping over fields, but record the total length,
%% Each field is <(FieldNum bsl 3) bor FieldType> ++ <FieldValue>
%% Record the length because varints may be non-optimally encoded.
%%
%% Groups can be nested, but assume the same FieldNum cannot be nested
%% because group field numbers are shared with the rest of the fields
%% numbers. Thus we can search just for an group-end with the same
%% field number.
%%
%% (The only time the same group field number could occur would
%% be in a nested sub message, but then it would be inside a
%% length-delimited entry, which we skip-read by length.)
read_gr_b(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen, FieldNum)
  when N < (32-7) ->
    read_gr_b(Tl, N+7, X bsl N + Acc, NumBytes, TagLen+1, FieldNum);
read_gr_b(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, TagLen,
          FieldNum) ->
    Key = X bsl N + Acc,
    TagLen1 = TagLen + 1,
    case {Key bsr 3, Key band 7} of
        {FieldNum, 4} -> % 4 = group_end
            {NumBytes, TagLen1};
        {_, 0} -> % 0 = varint
            read_gr_vi(Tl, 0, NumBytes + TagLen1, FieldNum);
        {_, 1} -> % 1 = bits64
            <<_:64, Tl2/binary>> = Tl,
            read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 8, 0, FieldNum);
        {_, 2} -> % 2 = length_delimited
            read_gr_ld(Tl, 0, 0, NumBytes + TagLen1, FieldNum);
        {_, 3} -> % 3 = group_start
            read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum);
        {_, 4} -> % 4 = group_end
            read_gr_b(Tl, 0, 0, NumBytes + TagLen1, 0, FieldNum);
        {_, 5} -> % 5 = bits32
            <<_:32, Tl2/binary>> = Tl,
            read_gr_b(Tl2, 0, 0, NumBytes + TagLen1 + 4, 0, FieldNum)
    end.

read_gr_vi(<<1:1, _:7, Tl/binary>>, N, NumBytes, FieldNum)
  when N < (64-7) ->
    read_gr_vi(Tl, N+7, NumBytes+1, FieldNum);
read_gr_vi(<<0:1, _:7, Tl/binary>>, _, NumBytes, FieldNum) ->
    read_gr_b(Tl, 0, 0, NumBytes+1, 0, FieldNum).

read_gr_ld(<<1:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum)
  when N < (64-7) ->
    read_gr_ld(Tl, N+7, X bsl N + Acc, NumBytes+1, FieldNum);
read_gr_ld(<<0:1, X:7, Tl/binary>>, N, Acc, NumBytes, FieldNum) ->
    Len = X bsl N + Acc,
    NumBytes1 = NumBytes + 1,
    <<_:Len/binary, Tl2/binary>> = Tl,
    read_gr_b(Tl2, 0, 0, NumBytes1 + Len, 0, FieldNum).

merge_msgs(Prev, New, MsgName) when is_atom(MsgName) ->
    merge_msgs(Prev, New, MsgName, []).

merge_msgs(Prev, New, MsgName, Opts) ->
    TrUserData = proplists:get_value(user_data, Opts),
    case MsgName of
      'Package' -> merge_msg_Package(Prev, New, TrUserData);
      'Release' -> merge_msg_Release(Prev, New, TrUserData);
      'RetirementStatus' ->
	  merge_msg_RetirementStatus(Prev, New, TrUserData);
      'Dependency' ->
	  merge_msg_Dependency(Prev, New, TrUserData)
    end.

-compile({nowarn_unused_function,merge_msg_Package/3}).
merge_msg_Package(#{} = PMsg,
		  #{name := NFname, repository := NFrepository} = NMsg,
		  TrUserData) ->
    S1 = #{name => NFname, repository => NFrepository},
    case {PMsg, NMsg} of
      {#{releases := PFreleases},
       #{releases := NFreleases}} ->
	  S1#{releases =>
		  'erlang_++'(PFreleases, NFreleases, TrUserData)};
      {_, #{releases := NFreleases}} ->
	  S1#{releases => NFreleases};
      {#{releases := PFreleases}, _} ->
	  S1#{releases => PFreleases};
      {_, _} -> S1
    end.

-compile({nowarn_unused_function,merge_msg_Release/3}).
merge_msg_Release(#{} = PMsg,
		  #{version := NFversion, checksum := NFchecksum} = NMsg,
		  TrUserData) ->
    S1 = #{version => NFversion, checksum => NFchecksum},
    S2 = case {PMsg, NMsg} of
	   {#{dependencies := PFdependencies},
	    #{dependencies := NFdependencies}} ->
	       S1#{dependencies =>
		       'erlang_++'(PFdependencies, NFdependencies,
				   TrUserData)};
	   {_, #{dependencies := NFdependencies}} ->
	       S1#{dependencies => NFdependencies};
	   {#{dependencies := PFdependencies}, _} ->
	       S1#{dependencies => PFdependencies};
	   {_, _} -> S1
	 end,
    case {PMsg, NMsg} of
      {#{retired := PFretired}, #{retired := NFretired}} ->
	  S2#{retired =>
		  merge_msg_RetirementStatus(PFretired, NFretired,
					     TrUserData)};
      {_, #{retired := NFretired}} ->
	  S2#{retired => NFretired};
      {#{retired := PFretired}, _} ->
	  S2#{retired => PFretired};
      {_, _} -> S2
    end.

-compile({nowarn_unused_function,merge_msg_RetirementStatus/3}).
merge_msg_RetirementStatus(#{} = PMsg,
			   #{reason := NFreason} = NMsg, _) ->
    S1 = #{reason => NFreason},
    case {PMsg, NMsg} of
      {_, #{message := NFmessage}} ->
	  S1#{message => NFmessage};
      {#{message := PFmessage}, _} ->
	  S1#{message => PFmessage};
      _ -> S1
    end.

-compile({nowarn_unused_function,merge_msg_Dependency/3}).
merge_msg_Dependency(#{} = PMsg,
		     #{package := NFpackage, requirement := NFrequirement} =
			 NMsg,
		     _) ->
    S1 = #{package => NFpackage,
	   requirement => NFrequirement},
    S2 = case {PMsg, NMsg} of
	   {_, #{optional := NFoptional}} ->
	       S1#{optional => NFoptional};
	   {#{optional := PFoptional}, _} ->
	       S1#{optional => PFoptional};
	   _ -> S1
	 end,
    S3 = case {PMsg, NMsg} of
	   {_, #{app := NFapp}} -> S2#{app => NFapp};
	   {#{app := PFapp}, _} -> S2#{app => PFapp};
	   _ -> S2
	 end,
    case {PMsg, NMsg} of
      {_, #{repository := NFrepository}} ->
	  S3#{repository => NFrepository};
      {#{repository := PFrepository}, _} ->
	  S3#{repository => PFrepository};
      _ -> S3
    end.


verify_msg(Msg, MsgName) when is_atom(MsgName) ->
    verify_msg(Msg, MsgName, []).

verify_msg(Msg, MsgName, Opts) ->
    TrUserData = proplists:get_value(user_data, Opts),
    case MsgName of
      'Package' -> v_msg_Package(Msg, [MsgName], TrUserData);
      'Release' -> v_msg_Release(Msg, [MsgName], TrUserData);
      'RetirementStatus' ->
	  v_msg_RetirementStatus(Msg, [MsgName], TrUserData);
      'Dependency' ->
	  v_msg_Dependency(Msg, [MsgName], TrUserData);
      _ -> mk_type_error(not_a_known_message, Msg, [])
    end.


-compile({nowarn_unused_function,v_msg_Package/3}).
v_msg_Package(#{name := F2, repository := F3} = M, Path,
	      TrUserData) ->
    case M of
      #{releases := F1} ->
	  if is_list(F1) ->
		 _ = [v_msg_Release(Elem, [releases | Path], TrUserData)
		      || Elem <- F1],
		 ok;
	     true ->
		 mk_type_error({invalid_list_of, {msg, 'Release'}}, F1,
			       [releases | Path])
	  end;
      _ -> ok
    end,
    v_type_string(F2, [name | Path], TrUserData),
    v_type_string(F3, [repository | Path], TrUserData),
    lists:foreach(fun (releases) -> ok;
		      (name) -> ok;
		      (repository) -> ok;
		      (OtherKey) ->
			  mk_type_error({extraneous_key, OtherKey}, M, Path)
		  end,
		  maps:keys(M)),
    ok;
v_msg_Package(M, Path, _TrUserData) when is_map(M) ->
    mk_type_error({missing_fields,
		   [name, repository] -- maps:keys(M), 'Package'},
		  M, Path);
v_msg_Package(X, Path, _TrUserData) ->
    mk_type_error({expected_msg, 'Package'}, X, Path).

-compile({nowarn_unused_function,v_msg_Release/3}).
v_msg_Release(#{version := F1, checksum := F2} = M,
	      Path, TrUserData) ->
    v_type_string(F1, [version | Path], TrUserData),
    v_type_bytes(F2, [checksum | Path], TrUserData),
    case M of
      #{dependencies := F3} ->
	  if is_list(F3) ->
		 _ = [v_msg_Dependency(Elem, [dependencies | Path],
				       TrUserData)
		      || Elem <- F3],
		 ok;
	     true ->
		 mk_type_error({invalid_list_of, {msg, 'Dependency'}},
			       F3, [dependencies | Path])
	  end;
      _ -> ok
    end,
    case M of
      #{retired := F4} ->
	  v_msg_RetirementStatus(F4, [retired | Path],
				 TrUserData);
      _ -> ok
    end,
    lists:foreach(fun (version) -> ok;
		      (checksum) -> ok;
		      (dependencies) -> ok;
		      (retired) -> ok;
		      (OtherKey) ->
			  mk_type_error({extraneous_key, OtherKey}, M, Path)
		  end,
		  maps:keys(M)),
    ok;
v_msg_Release(M, Path, _TrUserData) when is_map(M) ->
    mk_type_error({missing_fields,
		   [version, checksum] -- maps:keys(M), 'Release'},
		  M, Path);
v_msg_Release(X, Path, _TrUserData) ->
    mk_type_error({expected_msg, 'Release'}, X, Path).

-compile({nowarn_unused_function,v_msg_RetirementStatus/3}).
v_msg_RetirementStatus(#{reason := F1} = M, Path,
		       TrUserData) ->
    v_enum_RetirementReason(F1, [reason | Path],
			    TrUserData),
    case M of
      #{message := F2} ->
	  v_type_string(F2, [message | Path], TrUserData);
      _ -> ok
    end,
    lists:foreach(fun (reason) -> ok;
		      (message) -> ok;
		      (OtherKey) ->
			  mk_type_error({extraneous_key, OtherKey}, M, Path)
		  end,
		  maps:keys(M)),
    ok;
v_msg_RetirementStatus(M, Path, _TrUserData)
    when is_map(M) ->
    mk_type_error({missing_fields, [reason] -- maps:keys(M),
		   'RetirementStatus'},
		  M, Path);
v_msg_RetirementStatus(X, Path, _TrUserData) ->
    mk_type_error({expected_msg, 'RetirementStatus'}, X,
		  Path).

-compile({nowarn_unused_function,v_msg_Dependency/3}).
v_msg_Dependency(#{package := F1, requirement := F2} =
		     M,
		 Path, TrUserData) ->
    v_type_string(F1, [package | Path], TrUserData),
    v_type_string(F2, [requirement | Path], TrUserData),
    case M of
      #{optional := F3} ->
	  v_type_bool(F3, [optional | Path], TrUserData);
      _ -> ok
    end,
    case M of
      #{app := F4} ->
	  v_type_string(F4, [app | Path], TrUserData);
      _ -> ok
    end,
    case M of
      #{repository := F5} ->
	  v_type_string(F5, [repository | Path], TrUserData);
      _ -> ok
    end,
    lists:foreach(fun (package) -> ok;
		      (requirement) -> ok;
		      (optional) -> ok;
		      (app) -> ok;
		      (repository) -> ok;
		      (OtherKey) ->
			  mk_type_error({extraneous_key, OtherKey}, M, Path)
		  end,
		  maps:keys(M)),
    ok;
v_msg_Dependency(M, Path, _TrUserData) when is_map(M) ->
    mk_type_error({missing_fields,
		   [package, requirement] -- maps:keys(M), 'Dependency'},
		  M, Path);
v_msg_Dependency(X, Path, _TrUserData) ->
    mk_type_error({expected_msg, 'Dependency'}, X, Path).

-compile({nowarn_unused_function,v_enum_RetirementReason/3}).
v_enum_RetirementReason('RETIRED_OTHER', _Path,
			_TrUserData) ->
    ok;
v_enum_RetirementReason('RETIRED_INVALID', _Path,
			_TrUserData) ->
    ok;
v_enum_RetirementReason('RETIRED_SECURITY', _Path,
			_TrUserData) ->
    ok;
v_enum_RetirementReason('RETIRED_DEPRECATED', _Path,
			_TrUserData) ->
    ok;
v_enum_RetirementReason('RETIRED_RENAMED', _Path,
			_TrUserData) ->
    ok;
v_enum_RetirementReason(V, Path, TrUserData)
    when is_integer(V) ->
    v_type_sint32(V, Path, TrUserData);
v_enum_RetirementReason(X, Path, _TrUserData) ->
    mk_type_error({invalid_enum, 'RetirementReason'}, X,
		  Path).

-compile({nowarn_unused_function,v_type_sint32/3}).
v_type_sint32(N, _Path, _TrUserData)
    when -2147483648 =< N, N =< 2147483647 ->
    ok;
v_type_sint32(N, Path, _TrUserData)
    when is_integer(N) ->
    mk_type_error({value_out_of_range, sint32, signed, 32},
		  N, Path);
v_type_sint32(X, Path, _TrUserData) ->
    mk_type_error({bad_integer, sint32, signed, 32}, X,
		  Path).

-compile({nowarn_unused_function,v_type_bool/3}).
v_type_bool(false, _Path, _TrUserData) -> ok;
v_type_bool(true, _Path, _TrUserData) -> ok;
v_type_bool(0, _Path, _TrUserData) -> ok;
v_type_bool(1, _Path, _TrUserData) -> ok;
v_type_bool(X, Path, _TrUserData) ->
    mk_type_error(bad_boolean_value, X, Path).

-compile({nowarn_unused_function,v_type_string/3}).
v_type_string(S, Path, _TrUserData)
    when is_list(S); is_binary(S) ->
    try unicode:characters_to_binary(S) of
      B when is_binary(B) -> ok;
      {error, _, _} ->
	  mk_type_error(bad_unicode_string, S, Path)
    catch
      error:badarg ->
	  mk_type_error(bad_unicode_string, S, Path)
    end;
v_type_string(X, Path, _TrUserData) ->
    mk_type_error(bad_unicode_string, X, Path).

-compile({nowarn_unused_function,v_type_bytes/3}).
v_type_bytes(B, _Path, _TrUserData) when is_binary(B) ->
    ok;
v_type_bytes(B, _Path, _TrUserData) when is_list(B) ->
    ok;
v_type_bytes(X, Path, _TrUserData) ->
    mk_type_error(bad_binary_value, X, Path).

-compile({nowarn_unused_function,mk_type_error/3}).
-spec mk_type_error(_, _, list()) -> no_return().
mk_type_error(Error, ValueSeen, Path) ->
    Path2 = prettify_path(Path),
    erlang:error({gpb_type_error,
		  {Error, [{value, ValueSeen}, {path, Path2}]}}).


-compile({nowarn_unused_function,prettify_path/1}).
prettify_path([]) -> top_level;
prettify_path(PathR) ->
    list_to_atom(string:join(lists:map(fun atom_to_list/1,
				       lists:reverse(PathR)),
			     ".")).


-compile({nowarn_unused_function,id/2}).
-compile({inline,id/2}).
id(X, _TrUserData) -> X.

-compile({nowarn_unused_function,v_ok/3}).
-compile({inline,v_ok/3}).
v_ok(_Value, _Path, _TrUserData) -> ok.

-compile({nowarn_unused_function,m_overwrite/3}).
-compile({inline,m_overwrite/3}).
m_overwrite(_Prev, New, _TrUserData) -> New.

-compile({nowarn_unused_function,cons/3}).
-compile({inline,cons/3}).
cons(Elem, Acc, _TrUserData) -> [Elem | Acc].

-compile({nowarn_unused_function,lists_reverse/2}).
-compile({inline,lists_reverse/2}).
'lists_reverse'(L, _TrUserData) -> lists:reverse(L).
-compile({nowarn_unused_function,'erlang_++'/3}).
-compile({inline,'erlang_++'/3}).
'erlang_++'(A, B, _TrUserData) -> A ++ B.

get_msg_defs() ->
    [{{enum, 'RetirementReason'},
      [{'RETIRED_OTHER', 0}, {'RETIRED_INVALID', 1},
       {'RETIRED_SECURITY', 2}, {'RETIRED_DEPRECATED', 3},
       {'RETIRED_RENAMED', 4}]},
     {{msg, 'Package'},
      [#{name => releases, fnum => 1, rnum => 2,
	 type => {msg, 'Release'}, occurrence => repeated,
	 opts => []},
       #{name => name, fnum => 2, rnum => 3, type => string,
	 occurrence => required, opts => []},
       #{name => repository, fnum => 3, rnum => 4,
	 type => string, occurrence => required, opts => []}]},
     {{msg, 'Release'},
      [#{name => version, fnum => 1, rnum => 2,
	 type => string, occurrence => required, opts => []},
       #{name => checksum, fnum => 2, rnum => 3, type => bytes,
	 occurrence => required, opts => []},
       #{name => dependencies, fnum => 3, rnum => 4,
	 type => {msg, 'Dependency'}, occurrence => repeated,
	 opts => []},
       #{name => retired, fnum => 4, rnum => 5,
	 type => {msg, 'RetirementStatus'},
	 occurrence => optional, opts => []}]},
     {{msg, 'RetirementStatus'},
      [#{name => reason, fnum => 1, rnum => 2,
	 type => {enum, 'RetirementReason'},
	 occurrence => required, opts => []},
       #{name => message, fnum => 2, rnum => 3, type => string,
	 occurrence => optional, opts => []}]},
     {{msg, 'Dependency'},
      [#{name => package, fnum => 1, rnum => 2,
	 type => string, occurrence => required, opts => []},
       #{name => requirement, fnum => 2, rnum => 3,
	 type => string, occurrence => required, opts => []},
       #{name => optional, fnum => 3, rnum => 4, type => bool,
	 occurrence => optional, opts => []},
       #{name => app, fnum => 4, rnum => 5, type => string,
	 occurrence => optional, opts => []},
       #{name => repository, fnum => 5, rnum => 6,
	 type => string, occurrence => optional, opts => []}]}].


get_msg_names() ->
    ['Package', 'Release', 'RetirementStatus',
     'Dependency'].


get_group_names() -> [].


get_msg_or_group_names() ->
    ['Package', 'Release', 'RetirementStatus',
     'Dependency'].


get_enum_names() -> ['RetirementReason'].


fetch_msg_def(MsgName) ->
    case find_msg_def(MsgName) of
      Fs when is_list(Fs) -> Fs;
      error -> erlang:error({no_such_msg, MsgName})
    end.


fetch_enum_def(EnumName) ->
    case find_enum_def(EnumName) of
      Es when is_list(Es) -> Es;
      error -> erlang:error({no_such_enum, EnumName})
    end.


find_msg_def('Package') ->
    [#{name => releases, fnum => 1, rnum => 2,
       type => {msg, 'Release'}, occurrence => repeated,
       opts => []},
     #{name => name, fnum => 2, rnum => 3, type => string,
       occurrence => required, opts => []},
     #{name => repository, fnum => 3, rnum => 4,
       type => string, occurrence => required, opts => []}];
find_msg_def('Release') ->
    [#{name => version, fnum => 1, rnum => 2,
       type => string, occurrence => required, opts => []},
     #{name => checksum, fnum => 2, rnum => 3, type => bytes,
       occurrence => required, opts => []},
     #{name => dependencies, fnum => 3, rnum => 4,
       type => {msg, 'Dependency'}, occurrence => repeated,
       opts => []},
     #{name => retired, fnum => 4, rnum => 5,
       type => {msg, 'RetirementStatus'},
       occurrence => optional, opts => []}];
find_msg_def('RetirementStatus') ->
    [#{name => reason, fnum => 1, rnum => 2,
       type => {enum, 'RetirementReason'},
       occurrence => required, opts => []},
     #{name => message, fnum => 2, rnum => 3, type => string,
       occurrence => optional, opts => []}];
find_msg_def('Dependency') ->
    [#{name => package, fnum => 1, rnum => 2,
       type => string, occurrence => required, opts => []},
     #{name => requirement, fnum => 2, rnum => 3,
       type => string, occurrence => required, opts => []},
     #{name => optional, fnum => 3, rnum => 4, type => bool,
       occurrence => optional, opts => []},
     #{name => app, fnum => 4, rnum => 5, type => string,
       occurrence => optional, opts => []},
     #{name => repository, fnum => 5, rnum => 6,
       type => string, occurrence => optional, opts => []}];
find_msg_def(_) -> error.


find_enum_def('RetirementReason') ->
    [{'RETIRED_OTHER', 0}, {'RETIRED_INVALID', 1},
     {'RETIRED_SECURITY', 2}, {'RETIRED_DEPRECATED', 3},
     {'RETIRED_RENAMED', 4}];
find_enum_def(_) -> error.


enum_symbol_by_value('RetirementReason', Value) ->
    enum_symbol_by_value_RetirementReason(Value).


enum_value_by_symbol('RetirementReason', Sym) ->
    enum_value_by_symbol_RetirementReason(Sym).


enum_symbol_by_value_RetirementReason(0) ->
    'RETIRED_OTHER';
enum_symbol_by_value_RetirementReason(1) ->
    'RETIRED_INVALID';
enum_symbol_by_value_RetirementReason(2) ->
    'RETIRED_SECURITY';
enum_symbol_by_value_RetirementReason(3) ->
    'RETIRED_DEPRECATED';
enum_symbol_by_value_RetirementReason(4) ->
    'RETIRED_RENAMED'.


enum_value_by_symbol_RetirementReason('RETIRED_OTHER') ->
    0;
enum_value_by_symbol_RetirementReason('RETIRED_INVALID') ->
    1;
enum_value_by_symbol_RetirementReason('RETIRED_SECURITY') ->
    2;
enum_value_by_symbol_RetirementReason('RETIRED_DEPRECATED') ->
    3;
enum_value_by_symbol_RetirementReason('RETIRED_RENAMED') ->
    4.


get_service_names() -> [].


get_service_def(_) -> error.


get_rpc_names(_) -> error.


find_rpc_def(_, _) -> error.



-spec fetch_rpc_def(_, _) -> no_return().
fetch_rpc_def(ServiceName, RpcName) ->
    erlang:error({no_such_rpc, ServiceName, RpcName}).


get_package_name() -> undefined.



gpb_version_as_string() ->
    "4.3.1".

gpb_version_as_list() ->
    [4,3,1].
