 
 (defn take-binary
   "Takes a binary value from `buffer`."
-  ^bytes [^Buffer buffer]
+  ^bytes [^MikronBuffer buffer]
   (take-bytes buffer (take-varint buffer)))
 
 (defn put-binary
   "Puts a binary value `value` to `buffer`."
-  [^Buffer buffer ^bytes value]
+  [^MikronBuffer buffer ^bytes value]
   (doto buffer
     (put-varint #?(:clj  (alength value)
                    :cljs (.-byteLength value)))

    #?(:clj  (.order buffer (if value ByteOrder/LITTLE_ENDIAN ByteOrder/BIG_ENDIAN))
       :cljs (set! le value))))

(deftype Buffer [^mikron.buffer.IMikronBitBuffer  bit-buffer
                 ^mikron.buffer.IMikronByteBuffer byte-buffer])

(defn get-bit-buffer
  "Gets the bit buffer of `buffer`."
  #?(:clj {:inline (fn [buffer]
                     (when-not (util/can-have-meta? buffer)
                       (throw (ex-info "Invalid buffer" {:buffer buffer})))
                     `(.-bit-buffer ~(vary-meta buffer assoc :tag `Buffer)))})
  ^mikron.buffer.IMikronBitBuffer [^Buffer buffer]
  (.-bit-buffer buffer))

(defn get-byte-buffer


(defn finalize
  "Finalizes `buffer`."
  ^MikronBuffer [^MikronBuffer buffer]
  (let [bit-position (get-bit-position buffer)]
    (when-not (== -1 bit-position)
      (put-byte-at buffer bit-position (get-bit-value buffer)))
