Simplify IByteBuffer interface

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Done
    • Priority: Major - P3
    • 2.0
    • Affects Version/s: None
    • Component/s: BSON
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      The IByteBuffer interface represents a logical byte buffer that might be backed by various means (contiguous, segmented, using buffers from a pool or not, etc...).

      But the IByteBuffer interface probably has too many methods. Many of the methods could be moved out to extension methods on the interface (so they only need to be implemented once).

      A new streamlined interface that deals only with the buffer abstraction could look like this:

      public interface IByteBuffer : IDisposable
      {
          // properties
          int Capacity { get; }
          int Length { get; set; }
      
          // methods
          void EnsureCapacity(int minimumCapacity);
          ArraySegment<byte> AccessBackingBytes(int offset, int limit);
      }
      

      This reduces the responsibility of this interface to a single responsibility, namely to represent a (possibly) segmented variable length byte array.

            Assignee:
            Robert Stam (Inactive)
            Reporter:
            Robert Stam (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: