code: public ByteArraySegment serialize(T object) throws IOException {
          val result = new EnhancedByteArrayOutputStream();
          serialize(result, object);
          return result.getData();
      }
docs: Serializes the given object to an in-memory buffer (RandomAccessOutputStream) and returns a view of it.
  
  @param object The object to serialize.
  @return An ArrayView which represents the serialized data. This provides a view (offset+length) into a Java byte
  array and has APIs to extract or copy the data out of there.
  @throws IOException If an IO Exception occurred.