clj-artnet.impl.protocol.codec.primitives
Low-level buffer read/write primitives for Art-Net codec. All functions operate on java.nio.ByteBuffer instances.
coerce-to-bytes
(coerce-to-bytes payload)Coerce payload to a byte-array. Accepts byte[], ByteBuffer, or sequential collection of integers.
ensure-header!
(ensure-header! buf)Validate Art-Net ID bytes at start of buffer. Throws if invalid.
ensure-null-terminated
(ensure-null-terminated data max-length)Ensure a byte array is null-terminated, adding terminator if needed.
payload-length
(payload-length payload)Get the length of payload (ByteBuffer, byte array, or sequential).
prepare-target
(prepare-target buf size)Prepare a ByteBuffer for writing with a specified capacity.
put-bytes!
(put-bytes! buf coll)Write a collection of bytes to buffer at current position.
put-fixed-string!
(put-fixed-string! buf s width)Write null-terminated ASCII string padded to fixed width.
put-u16-be!
(put-u16-be! buf v)Write big-endian uint16 to buffer at the current position.
put-u16-le!
(put-u16-le! buf v)Write little-endian uint16 to buffer at the current position.
put-uids!
(put-uids! buf uids)Write a sequence of RDM UIDs (6-byte sequences) to the buffer.
read-ascii
(read-ascii buf offset length)Read null-terminated ASCII string from buffer at offset with max length.
read-octets
(read-octets buf offset length)Read byte slice as a vector of unsigned integers.
safe-ubyte
(safe-ubyte buf idx)Read unsigned byte at index, returning 0 if out of bounds.
safe-uint16-be
(safe-uint16-be buf idx)Read big-endian uint16 at index, returning 0 if out of bounds.
write-payload!
(write-payload! buf payload)Write payload (ByteBuffer, byte array, or sequential) to the target buffer.