code: public static int streamableBytes(StreamByteDistributor.StreamState state) {
          return max(0, (int) min(state.pendingBytes(), state.windowSize()));
      }
docs: Calculate the amount of bytes that can be sent by {@code state}. The lower bound is {@code 0}.