binary icon indicating copy to clipboard operation
binary copied to clipboard

Public BinaryIO protocol or codec for `nil`

Open darkleaf opened this issue 6 years ago • 0 comments

Thanks for awesome library!

I need to serialize no value in some cases. For example:

(b/header :int-be
          (fn header->body-codec [length]
            (if (= -1 length)
              codec/null
              (b/blob :length length)))
          "not used")

So I add null codec. But it's ugly:

;; hack
(def null
  (b/compile-codec
   (byte-array 0)
   (constantly (byte-array 0))
   (constantly nil)))

Is it possible to make public BinaryIO protocol or add nil primitive codec?

darkleaf avatar May 12 '19 18:05 darkleaf