type argument =
  | Int32 of int32
  | Float32 of float
  | Str of string
  | Blob of string

let encode_float f =
  BITSTRING {
    Int32.bits_of_float f : 32 : bigendian
  }

let encode_int i =
  BITSTRING {
    i : 32 : bigendian
  }

let decode_float b =
  bitmatch b with {
    i : 4*8 : bigendian
  } ->
    Int32.float_of_bits i

let decode_int b =
  bitmatch b with {
    i : 4*8 : bigendian
  } -> i

type argument =
  | Int32 of int32
  | Float32 of float
  | Str of string
  | Blob of string

let encode_float f =
  BITSTRING {
    Int32.bits_of_float f : 32 : bigendian
  }

let encode_int i =
  BITSTRING {
    i : 32 : bigendian
  }

let read_float data =
  bitmatch data with {
    i : 4*8 : bigendian;
    rest : -1 : bitstring
  } ->
    Int32.float_of_bits i, rest

let read_int data =
  bitmatch data with {
    i : 4*8 : bigendian;
    rest : -1 : bitstring
  } -> i, rest

Change semantics of the decoding functions
Change semantics of the decoding functions

Functions now return both the decoded value, and the remaining part
of the bitstring.

Also rename decode_* to read_* in honour of the new semantics.

Signed-off-by: John Else <37b74501daa612e48fea94f9846ed4ddeb6a8f07@citrix.com>
