Skip to content

# pamqp.body

## `pamqp.body`

The :py:mod:`pamqp.body` module contains the :py:class:`Body` class which is used when unmarshalling body frames. When dealing with content frames, the message body will be returned from the library as an instance of the body class.

### `ContentBody`

ContentBody carries the value for an AMQP message body frame

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`value` | `bytes` | The value for the ContentBody frame | required

Source code in `pamqp/body.py`

    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45

    class ContentBody:
        """ContentBody carries the value for an AMQP message body frame

        :param value: The value for the ContentBody frame

        """

        name: typing.ClassVar[str] = 'ContentBody'

        def __init__(self, value: bytes) -> None:
            """Create a new instance of a ContentBody object"""
            self.value = value

        def __len__(self) -> int:
            """Return the length of the content body value"""
            return len(self.value) if self.value else 0

        def marshal(self) -> bytes:
            """Return the marshaled content body. This method is here for API
            compatibility, there is no special marshaling for the payload in a
            content frame.

            """
            return self.value

        def unmarshal(self, data: bytes) -> None:
            """Apply the data to the object. This method is here for API
            compatibility, there is no special unmarshalling for the payload in a
            content frame.

            :param data: The content body data from the frame

            """
            self.value = data

#### `__init__(value)`

Create a new instance of a ContentBody object

Source code in `pamqp/body.py`

    21
    22
    23

    def __init__(self, value: bytes) -> None:
        """Create a new instance of a ContentBody object"""
        self.value = value

#### `__len__()`

Return the length of the content body value

Source code in `pamqp/body.py`

    25
    26
    27

    def __len__(self) -> int:
        """Return the length of the content body value"""
        return len(self.value) if self.value else 0

#### `marshal()`

Return the marshaled content body. This method is here for API compatibility, there is no special marshaling for the payload in a content frame.

Source code in `pamqp/body.py`

    29
    30
    31
    32
    33
    34
    35

    def marshal(self) -> bytes:
        """Return the marshaled content body. This method is here for API
        compatibility, there is no special marshaling for the payload in a
        content frame.

        """
        return self.value

#### `unmarshal(data)`

Apply the data to the object. This method is here for API compatibility, there is no special unmarshalling for the payload in a content frame.

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`data` | `bytes` | The content body data from the frame | required

Source code in `pamqp/body.py`

    37
    38
    39
    40
    41
    42
    43
    44
    45

    def unmarshal(self, data: bytes) -> None:
        """Apply the data to the object. This method is here for API
        compatibility, there is no special unmarshalling for the payload in a
        content frame.

        :param data: The content body data from the frame

        """
        self.value = data