buffy icon indicating copy to clipboard operation
buffy copied to clipboard

Issue running sample in README

Open lbradstreet opened this issue 11 years ago • 6 comments

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

lbradstreet avatar Mar 10 '15 17:03 lbradstreet

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.

ifesdjeen avatar Mar 10 '15 19:03 ifesdjeen

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

lbradstreet avatar Mar 11 '15 03:03 lbradstreet

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!

ifesdjeen avatar Mar 11 '15 07:03 ifesdjeen

@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 avatar Aug 03 '16 09:08 bcambel

@bcambel yes, sorry, it somehow got lost in the pit of my todo list. I'll check it out over the weekend.

ifesdjeen avatar Aug 03 '16 09:08 ifesdjeen

@ifesdjeen thanks!

bcambel avatar Aug 10 '16 06:08 bcambel