.. index:: single: message_pack(StringRepresentation)
.. _message_pack/1:

.. rst-class:: right

**object**

``message_pack(StringRepresentation)``
======================================

* ``StringRepresentation`` - Text representation to be used when decoding MessagePack strings. Possible values are ``atom`` (default), ``chars``, and ``codes``.


MessagePack format exporter and importer.

| **Availability:** 
|    ``logtalk_load(message_pack(loader))``

| **Author:** Paulo Moura
| **Version:** 1:1:1
| **Date:** 2026-06-14

| **Compilation flags:**
|    ``static, context_switching_calls``


| **Uses:**
|    :ref:`ieee_754(Precision,ByteOrder,NaNRepresentation) <ieee_754/3>`
|    :ref:`list <list/0>`
|    :ref:`type <type/0>`
|    :ref:`utf_8 <utf_8/0>`

| **Remarks:**
|    (none)

| **Inherited public predicates:**
|    (none)

.. contents::
   :local:
   :backlinks: top

Public predicates
-----------------

.. index:: parse/2
.. _message_pack/1::parse/2:

``parse/2``
^^^^^^^^^^^

Parses a list of bytes in the MessagePack format returning the corresponding term representation. Throws an error when parsing is not possible (usually due to an invalid byte sequence).

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``parse(Bytes,Term)``
| **Mode and number of proofs:**
|    ``parse(@list(byte),-ground)`` - ``one_or_error``

| **Exceptions:**
|    ``Bytes`` is not ground:
|        ``instantiation_error``
|    ``Bytes`` is ground but not a valid MessagePack byte sequence:
|        ``domain_error(message_pack_byte_sequence,Bytes)``


------------

.. index:: generate/2
.. _message_pack/1::generate/2:

``generate/2``
^^^^^^^^^^^^^^

Generates a list of bytes in the MessagePack format representing the given term. Throws an error when generating is not possible (usually due to a term with no corresponding MessagePack representation).

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``generate(Term,Bytes)``
| **Mode and number of proofs:**
|    ``generate(@ground,-list(byte))`` - ``one_or_error``

| **Exceptions:**
|    ``Term`` is a variable:
|        ``instantiation_error``
|    ``Term`` has no corresponding MessagePack representation:
|        ``domain_error(message_pack_term,Term)``


------------

Protected predicates
--------------------

(no local declarations; see entity ancestors if any)

Private predicates
------------------

(no local declarations; see entity ancestors if any)

Operators
---------

(none)

