smee / binary

Clojure API for binary format I/O using java's stream apis
75 stars 10 forks source link

Binary utilities #18

Open WhittlesJr opened 5 years ago

WhittlesJr commented 5 years ago

Hi! So I recently (finally) (sort of) finished my BACnet implementation. I ended up with a bunch of generic utility functions. I'd much prefer to contribute to an existing project, rather than spin off a new one, so I thought I'd ask if you'd want to merge any or all of the following as a separate util namespace?

https://gist.github.com/WhittlesJr/dd94e7e4d9e21460b4dd9cd31b9fcaa1

The "util.core" namespace has more generic functions. I'm thinking of making a separate library for my map-matching functions, but I included them in the gist so you could see what they are.

I included the npdu example so you can get a sense for my use case, but it's just a small part of the BACnet protocol.

smee commented 5 years ago

I will have a look as soon as I can find the time. Thanks for suggesting these.

WhittlesJr commented 5 years ago

After discovering graph and specter, I was able to drastically cut down the amount of helper functions.

Here's what my binary utility NS has been reduced to:

https://gist.github.com/WhittlesJr/b5bdc6880d7639ec795a1e293af70a34

WhittlesJr commented 5 years ago

The complex-bytes-related stuff could be removed also if we could come up with a codec for bit.

WhittlesJr commented 5 years ago

Any thought on these helper functions? I've come to the point that I have had to split them off from my BACnet repository into a separate library to share between several projects of mine. I'm sure many of them are not as generic as I think they are but possibly a few of them would be helpful generally.