   ([default]
    (reify
      IStaticSize
-     (size [_] (Integer/BYTES))
-
-     ISpec
-     (read [_ buff pos]
-       [(Integer/BYTES)
+     (size [_] 4)
+
+     ISpec
+     (read [s buff pos]
+       [(proto/size s)
         (buffer/read-int buff pos)])
 
-     (write [_ buff pos value]
+     (write [s buff pos value]
        (let [value (or value default)]
          (buffer/write-int buff pos value)
-         (Integer/BYTES))))))
+         (proto/size s))))))
 
 (defn int64
   "Long type spec constructor."

  ([default]
   (reify
     IStaticSize
     (size [_] (Long/BYTES))

     ISpec
     (read [_ buff pos]
       [(Long/BYTES)
        (buffer/read-long buff pos)])

     (write [_ buff pos value]
       (let [value (or value default)]
         (buffer/write-long buff pos value)
         (Long/BYTES))))))

(defn real32
  "Float type spec constructor."
  ([] (real32 0))
  ([default]
   (reify
     IStaticSize
     (size [_] (Float/BYTES))

     ISpec
     (read [_ buff pos]
       [(Float/BYTES)
        (buffer/read-float buff pos)])

     (write [_ buff pos value]
       (let [value (or value default)]
         (buffer/write-float buff pos value)
         (Float/BYTES))))))

(defn real64
  "Double type spec constructor."
  ([] (real64 0))
  ([default]
   (reify
     IStaticSize
     (size [_] (Double/BYTES))

     ISpec
     (read [_ buff pos]
       [(Double/BYTES)
        (buffer/read-double buff pos)])

     (write [_ buff pos value]
       (let [value (or value default)]
         (buffer/write-double buff pos value)
         (Double/BYTES))))))

(defn bytes
  "Fixed size byte array type spec constructor."

  ([default]
   (reify
     IStaticSize
     (size [_] 2)

     ISpec
     (read [s buff pos]
       [(proto/size s)
        (buffer/read-short buff pos)])

     (write [s buff pos value]
       (let [value (or value default)]
         (buffer/write-short buff pos value)
         (proto/size s))))))

(defn int32
  "Integer type spec constructor."
