private static Flow ReadFlow()

in src/Proton/Codec/Decoders/Transport/FlowTypeDecoder.cs [67:142]


      private static Flow ReadFlow(IProtonBuffer buffer, IDecoderState state, IListTypeDecoder listDecoder)
      {
         Flow result = new();

         _ = listDecoder.ReadSize(buffer, state);
         int count = listDecoder.ReadCount(buffer, state);

         if (count < MinFlowListEntries)
         {
            throw new DecodeException(ErrorForMissingRequiredFields(count));
         }

         if (count > MaxFlowListEntries)
         {
            throw new DecodeException("To many entries in Flow list encoding: " + count);
         }

         for (int index = 0; index < count; ++index)
         {
            // Peek ahead and see if there is a null in the next slot, if so we don't call
            // the setter for that entry to ensure the returned type reflects the encoded
            // state in the modification entry.
            bool nullValue = buffer.GetByte(buffer.ReadOffset) == (byte)EncodingCodes.Null;
            if (nullValue)
            {
               // Ensure mandatory fields are set but account for the nextIncomingId
               // being optional for the Flow performative.
               if (index > 0 && index < MinFlowListEntries)
               {
                  throw new DecodeException(ErrorForMissingRequiredFields(index));
               }

               buffer.ReadOffset += 1;
               continue;
            }

            switch (index)
            {
               case 0:
                  result.NextIncomingId = state.Decoder.ReadUnsignedInteger(buffer, state) ?? 0;
                  break;
               case 1:
                  result.IncomingWindow = state.Decoder.ReadUnsignedInteger(buffer, state) ?? 0;
                  break;
               case 2:
                  result.NextOutgoingId = state.Decoder.ReadUnsignedInteger(buffer, state) ?? 0;
                  break;
               case 3:
                  result.OutgoingWindow = state.Decoder.ReadUnsignedInteger(buffer, state) ?? 0;
                  break;
               case 4:
                  result.Handle = state.Decoder.ReadUnsignedInteger(buffer, state) ?? 0;
                  break;
               case 5:
                  result.DeliveryCount = state.Decoder.ReadUnsignedInteger(buffer, state) ?? 0;
                  break;
               case 6:
                  result.LinkCredit = state.Decoder.ReadUnsignedInteger(buffer, state) ?? 0;
                  break;
               case 7:
                  result.Available = state.Decoder.ReadUnsignedInteger(buffer, state) ?? 0;
                  break;
               case 8:
                  result.Drain = state.Decoder.ReadBoolean(buffer, state) ?? false;
                  break;
               case 9:
                  result.Echo = state.Decoder.ReadBoolean(buffer, state) ?? false;
                  break;
               case 10:
                  result.Properties = state.Decoder.ReadMap<Symbol, object>(buffer, state);
                  break;
            }
         }

         return result;
      }