anchor.diff:      throw({error,malformed_packet}).
   
   %% If the Will Flag is set to 0, then the Will QoS MUST be set to 0 (0x00) [MQTT-3.1.2-13]
  -parse_will_details_maybe(_WillFlag = 0,_WillRetain,_WillQoS = 0,Buffer) ->
  +maybe_parse_will_details(_WillFlag = 0,_WillRetain,_WillQoS = 0,Buffer) ->
       {ok,undefined,Buffer};
   
  -parse_will_details_maybe(_WillFlag = 1,WillRetain,WillQoS,Buffer) when WillQoS =< 2 ->
  +maybe_parse_will_details(_WillFlag = 1,WillRetain,WillQoS,Buffer) when WillQoS =< 2 ->
       {ok,WillTopic, Rest1} =  parse_string(Buffer),
       {ok,WillMessage, Rest2} =  parse_string(Rest1),
       {
  
positive.code:     Payload/binary>>}) ->
  
      {ok,ClientId, Rest} = parse_string(S#parse_state{buffer=Payload}), %% 3.1.3.1 does not place strict limitations on the ClientId
      {ok, WillDetails,Rest3} = parse_will_details_maybe(WillFlag,WillRetain,WillQoS,Rest),
      {Username,Rest4} = parse_string_maybe(UsernameFlag,Rest3),
      {Password,<<>>} =  parse_string_maybe(PasswordFlag,Rest4),
      #'CONNECT'{
          protocol_name = ProtocolName,
          protocol_version = ProtocolLevel,
  
negative.code: 
  parse_specific_type(?PUBLISH,<<Dup:1,QoS:2,Retain:1>>,S) when QoS =< 2 ->
  
      %% validate flags - @todo: should we do that here? or in the connection process???
      case {Dup,QoS,Retain} of
          {1,0,_}->
              throw({error,invalid_flags});
  