Skip to content

Public BinaryIO protocol or codec for nil #19

@darkleaf

Description

@darkleaf

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions