chez-libs

(data bare)
Login

BARE Encoding

Synopsis

(import (data bare))

Read or write BARE message encoding.

Error Handling

condition: &bare-i/o

Condition type derived from &i/o-port. Used to represent decoding errors.

procedure: (make-bare-i/o-error port)

Create an instance of &i/o-port encapsulating the port where the offending encoding was found.

procedure: (bare-i/o-error? any)

Predicate to recognize &i/o-port conditions.

procedure: (bare-i/o-errorf who port string format-arg ...)

Raise a new composite condition including &i/o-port, containing the location symbol who, the given port, and a message constructed from the string and format arguments.

I/O Operations

procedure: (get-uint port max-size)

procedure: (get-uint port)

Read an unsigned integer in variable length encoding. Optionally, an explicit max-size in bytes may be specified, or #f may be passed to lift the restriction.

procedure: (get-int port max-size)

procedure: (get-int port)

Read a signed integer in variable length encoding. Optionally, an explicit max-size in bytes may be specified, or #f may be passed to lift the restriction.

procedure: (put-uint port integer max-size)

procedure: (put-uint port integer)

Write an unsigned integer in variable length encoding. Optionally, an explicit max-size in bytes may be specified, or #f may be passed to lift the restriction.

procedure: (put-int port integer max-size)

procedure: (put-int port integer)

Write a signed integer in variable length encoding. Optionally, an explicit max-size in bytes may be specified, or #f may be passed to lift the restriction.

procedure: (get-bytevector/length port)

Read an integer size field and a sequence of bytes.

procedure: (put-bytevector/length port bytevector)

Write an integer size field and a sequence of bytes.

procedure: (get-string/length port)

Read an integer size field and a sequence of UTF-8 characters.

procedure: (put-string/length port string)

Write an integer size field and a sequence of UTF-8 characters.

procedure: (get-bool port)

Read a single byte representing a boolean.

procedure: (put-bool port bool)

Write a single byte representing a boolean.

procedure: ((get-optional get-value) port)

Read a single byte guard flag, and if true use get-value to read a payload. Return #f or the payload read.

procedure: ((put-optional put-value) port value)

Write a single byte guard flag, and if true use put-value to write the payload.