sfertman/easy-rpc

Parse bytes function args

Closed this issue · 1 comments

A binary function argument could be represented as something like this:

":b:bin::00100111010110100111101010"
":b:hex::90139480909abcdef"
":b:base-64::9834dj9843djnkwjecn9348ncn9348cn/="

where

  • :b: means that this string should be parsed as binary data
  • bin, hex, etc: denotes the encoding
  • and whatever comes after the delimiter :: is the actual data

We can parse it pretty easily:

user=> (re-matches #"^:b:(bin|hex|base-64)::(.*)" "b:bin:00100111010110100111101010")

Note: better to re-matches on (.substring s 0 n) instead of the entirety of s which might be large.

Done