-
-
Save joshrotenberg/8c3da82eb9183baae5b1 to your computer and use it in GitHub Desktop.
gloss problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use 'gloss.io 'gloss.core) | |
(defcodec r {:m (string :utf-8 :length 4) | |
:t :uint32 | |
:s :uint32 | |
:d (string :utf-8)}) | |
(def g (encode r {:m "food" :t 2 :s 4 :d "barf"})) | |
;;user> g | |
;;(#<HeapByteBuffer java.nio.HeapByteBuffer[pos=0 lim=4 cap=4]> #<HeapByteBuffer java.nio.HeapByteBuffer[pos=0 lim=4 cap=4]> #<HeapByteBuffer java.nio.HeapByteBuffer[pos=0 lim=4 cap=4]> #<HeapByteBuffer java.nio.HeapByteBuffer[pos=0 lim=4 cap=4]>) | |
(decode r g) | |
;;Insufficient bytes to decode frame. | |
;; [Thrown class java.lang.Exception] | |
;; same issue with code from the gloss wiki | |
(defcodec animal (enum :int16 :dog :cat :horse)) | |
(defcodec pet | |
{:name (string :utf-8 :delimiter "\n") | |
:type animal}) | |
(def goober (encode pet {:name "goober" :type :cat})) | |
(decode pet goober) | |
Insufficient bytes to decode frame. | |
[Thrown class java.lang.Exception] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment