Utilities¶ veltix.utils.encoding ¶ Encoding utilities for message serialization. encode_utf8 ¶ encode_utf8(data: str | bytes) -> bytes Encode string or bytes to UTF-8. decode_utf8 ¶ decode_utf8(data: bytes) -> str Decode UTF-8 bytes to string. encode_json ¶ encode_json(data: Any) -> bytes Encode data to JSON bytes. decode_json ¶ decode_json(data: bytes) -> Any Decode JSON bytes to Python object. veltix.utils.format_size ¶ format_bytes ¶ format_bytes(size: int) -> str Format a byte count into a human-readable string. Parameters: Name Type Description Default size int Size in bytes. required Returns: Type Description str Human-readable string (e.g. '148 KB', '3.07 MB'). Examples: >>> format_bytes(148) '148 B' >>> format_bytes(148_000) '144.5 KB' >>> format_bytes(3_000_000) '2.86 MB'