Open lbradstreet opened 9 years ago
Hi Lucas,
Probably what you're looking for is this exapmle:
(ns clojurewerkz.buffy.core-test
(:refer-clojure :exclude [read])
(:require [clojure.test :refer :all]
[clojurewerkz.buffy.util :refer :all]
[clojurewerkz.buffy.core :refer :all]
[clojurewerkz.buffy.types.protocols :refer :all]))
(deftest complete-access-test
(let [s (spec :first-field (int32-type)
:second-field (string-type 10)
:third-field (boolean-type))
b (compose-buffer s)]
(compose b {:first-field 101
:second-field "string"
:third-field true})
(is (= {:third-field true :second-field "string" :first-field 101}
(decompose b)))))
Could you please point me to the place in README you've constructed your example from?.. It'd be good to improve the readme for future.
Hi @ifesdjeen Thanks for the quick reply.
I constructed the example from the dynamic frames section: https://github.com/clojurewerkz/buffy/blob/master/README.md#dynamic-frames
Code was from the following line: "It's implementation is a little bit more complex, but still reasonably simple. First, we define a dynamic string frame in the same manner as we made with netstrings:"
The actual issue is that I hadn't required clojurewerkz.buffy.types.protocols and was using read from clojure.core. clojurewerkz.buffy.types.protocols isn't mentioned in the README so it's kinda easy to go wrong.
Seems like it is the same issue discussed here: https://github.com/clojurewerkz/buffy/issues/18
I'd be happy to submit a PR.
Thanks again
That's true, yes... I think that should be changed. I'll check into the details. If you'd like to work on a PR - we're always happy to accept patches!
Thanks!
@michaelklishin @ifesdjeen do you have any plans to fix the issue within the README ?
I am having the following exception while running the same code
java.lang.IllegalArgumentException: No implementation of method: :decompose of protocol: #'clojurewerkz.buffy.core/Composable found for class: io.netty.buffer.UnpooledUnsafeDirectByteBuf
@bcambel yes, sorry, it somehow got lost in the pit of my todo list. I'll check it out over the weekend.
@ifesdjeen thanks!
First off, thank you for buffy, it seems like exactly what I need.
I'm having some trouble running the compose / decompose on the dynamic-type as it's described in the README.
I receive this error message:
CompilerException java.lang.IllegalArgumentException: No implementation of method: :decompose of protocol: #'clojurewerkz.buffy.core/Composable found for class: io.netty.buffer.UnpooledUnsafeDirectByteBuf, compiling:(buffy_test/core.clj:1:25)
For this minimal example extracted from the readme: https://github.com/lbradstreet/buffy-test/blob/master/src/buffy_test/core.clj
The only thing I could think I could possibly be doing wrong is using the wrong namespaces on the functions.
If you could just point me in the right directly I'll happily to solve things myself and provide a PR for the README (if required).
Thanks again,
Lucas