 (ns multicodec.core
   "Core multicodec protocols and functions."
+  (:require
+    [multicodec.header :as header])
   (:import
     (java.io
       ByteArrayInputStream

  [codec ^bytes byte-data]
  (let [bais (ByteArrayInputStream. byte-data)]
    (decode! codec bais)))

    (.toByteArray baos)))


(defn encode-with-header!
  "Writes a header to the output stream, then writes out the encoded value.
  Returns the number of bytes written.

  If a header is not given, the codec's header is used."
  ([codec output value]
   (encode-with-header! codec output (:header codec) value))
  ([codec output header value]
   (let [header-length (header/write-header! output header)
         body-length (encode! codec output value)]
     (+ header-length body-length))))



;; ## Decoding

