private static Flow ReadFlow()

in src/Proton/Codec/Decoders/Transport/FlowTypeDecoder.cs [173:254]


      private static Flow ReadFlow(Stream stream, IStreamDecoderState state, IListTypeDecoder listDecoder)
      {
         Flow result = new();

         _ = listDecoder.ReadSize(stream, state);
         int count = listDecoder.ReadCount(stream, 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.
            if (stream.CanSeek)
            {
               bool nullValue = stream.ReadByte() == (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));
                  }

                  continue;
               }
               else
               {
                  stream.Seek(-1, SeekOrigin.Current);
               }
            }

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

         return result;
      }