message: transport: add report function for receive buffer
diff: @@ -181,15 +181,7 @@ impl StreamReceiveBuffer {
  /// This equals the amount of data that is stored in contiguous fashion at
  /// the start of the buffer.
  pub fn len(&self) -> usize {
  - let mut result = 0;
  - for slot in &self.slots {
  - if let SlotState::Received(b) = slot {
  - result += b.len();
  - } else {
  - break; // We are only checking contiguous ready slots
  - }
  - }
  - result
  + self.report().0
  }
  /// Returns true if no bytes are available for reading
  @@ -197,6 +189,23 @@ impl StreamReceiveBuffer {
  self.len() == 0
  }
  + /// Returns the number of bytes and chunks available for consumption
  + #[inline]
  + pub fn report(&self) -> (usize, usize) {
  + let mut bytes = 0;
  + let mut chunks = 0;
  + for slot in &self.slots {
  + if let SlotState::Received(b) = slot {
  + bytes += b.len();
  + chunks += 1;
  + } else {
  + // only report contiguous ready slots
  + break;
  + }
  + }
  + (bytes, chunks)
  + }
  +
  /// Allocates a buffer of the configured buffer size.
  /// This currently just allocates from the heap. In the future it could use a custom allocator
  /// or object pool.
  