Solved:

(g/header
 (g/repeated :ubyte :prefix :ubyte)
 (fn [h]
   (g/finite-block (apply + h)))
 (fn [b]
        ...))

That did it.
                                                 
On Fri, Oct 10, 2014 at 10:32:59AM -0700, john walker wrote:
> What information do you want after this is decoded? Do you want the sum of 
> byte0 ... byten, as well as the actual payload? Do you also want the 
> header-length?
> 
> On Thursday, October 9, 2014 11:34:59 PM UTC-7, Ken Restivo wrote:
> >
> > I'm playing around with Gloss, trying to decode a packet, part of which 
> > has the following nested struture: 
> >
> > header-length (1 byte, value n) 
> >         byte0 ... byten (count defined by that header-length byte) 
> >            actual payload (length of which is the sum of the values of the 
> > above bytes) 
> >
> > So instead of a fixed-size value (uint16, uint32, uint64, etc) defining 
> > the size of the payload, there's a variable-length  list of bytes (up to 
> > 255),  which has to be summed, to determine the length of the payload. 
> >
> > Pretty easy to do imperatively, but I got lost in the dense forest of 
> > gloss's abstractions, and couldn't figure out if it makes sense to try to 
> > handle a case like this with it. 
> >
> > -ken 
> >
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> --- 
> You received this message because you are subscribed to the Google Groups 
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to