Smile.Constants (SmileEx v0.2.0)

View Source

Defines constants for the Smile binary format specification.

This module contains all token types, byte markers, and configuration values defined in the official Smile format specification. These constants are used by the encoder and decoder to ensure proper format compliance.

Header Constants

The Smile format starts with a 4-byte header:

  • Byte 1: 0x3A (ASCII ':')
  • Byte 2: 0x29 (ASCII ')')
  • Byte 3: 0x0A (ASCII '\n')
  • Byte 4: Version and flags byte

This creates the recognizable :)\n signature.

Token Types

The format defines various token types for different data:

  • Literal tokens (null, true, false, empty string)
  • Integer tokens (small int, 32-bit, 64-bit)
  • Float tokens (32-bit, 64-bit)
  • String tokens (tiny, small, long; ASCII and Unicode variants)
  • Structural tokens (array start/end, object start/end)
  • Back-reference tokens (shared names and values)

Optimization Limits

The format defines limits for various optimizations:

  • Maximum 1024 shared field names
  • Maximum 1024 shared string values
  • Maximum 64 bytes for short string values eligible for sharing
  • Maximum 56 bytes for short field names in Unicode

References

Based on the official specification: https://github.com/FasterXML/smile-format-specification

Summary

Functions

byte_marker_end_of_content()

byte_marker_end_of_string()

header_bit_has_raw_binary()

header_bit_has_shared_names()

header_bit_has_shared_string_values()

header_byte_1()

header_byte_2()

header_byte_3()

header_byte_4()

max_shared_names()

max_shared_string_length_bytes()

max_shared_string_values()

max_short_name_ascii_bytes()

max_short_name_unicode_bytes()

max_short_value_string_bytes()

min_buffer_for_possible_short_string()

token_byte_float_32()

token_byte_float_64()

token_byte_int_32()

token_byte_int_64()

token_key_empty_string()

token_key_long_string()

token_literal_empty_string()

token_literal_end_array()

token_literal_end_object()

token_literal_false()

token_literal_null()

token_literal_start_array()

token_literal_start_object()

token_literal_true()

token_misc_binary_7bit()

token_misc_binary_raw()

token_misc_float_32()

token_misc_float_64()

token_misc_float_big()

token_misc_integer_32()

token_misc_integer_64()

token_misc_integer_big()

token_misc_long_text_ascii()

token_misc_long_text_unicode()

token_prefix_fp()

token_prefix_integer()

token_prefix_key_ascii()

token_prefix_key_shared_long()

token_prefix_key_shared_short()

token_prefix_key_unicode()

token_prefix_misc_other()

token_prefix_shared_string_long()

token_prefix_shared_string_short()

token_prefix_short_unicode()

token_prefix_small_ascii()

token_prefix_small_int()

token_prefix_tiny_ascii()

token_prefix_tiny_unicode()