| 1 |
""" |
| 2 |
The :py:mod:`pamqp.body` module contains the :py:class:`Body` class which is |
| 3 |
used when unmarshalling body frames. When dealing with content frames, the |
| 4 |
message body will be returned from the library as an instance of the body |
| 5 |
class. |
| 6 |
|
| 7 |
""" |
| 8 |
|
| 9 |
import typing |
| 10 |
|
| 11 |
|
| 12 |
class ContentBody: |
| 13 |
"""ContentBody carries the value for an AMQP message body frame |
| 14 |
|
| 15 |
:param value: The value for the ContentBody frame |
| 16 |
|
| 17 |
""" |
| 18 |
|
| 19 |
name: typing.ClassVar[str] = 'ContentBody' |
| 20 |
|
| 21 |
def __init__(self, value: bytes) -> None: |
| 22 |
"""Create a new instance of a ContentBody object""" |
| 23 |
self.value = value |
| 24 |
|
| 25 |
def __len__(self) -> int: |
| 26 |
"""Return the length of the content body value""" |
| 27 |
return len(self.value) if self.value else 0 |
| 28 |
|
| 29 |
def marshal(self) -> bytes: |
| 30 |
"""Return the marshaled content body. This method is here for API |
| 31 |
compatibility, there is no special marshaling for the payload in a |
| 32 |
content frame. |
| 33 |
|
| 34 |
""" |
| 35 |
return self.value |
| 36 |
|
| 37 |
def unmarshal(self, data: bytes) -> None: |
| 38 |
"""Apply the data to the object. This method is here for API |
| 39 |
compatibility, there is no special unmarshalling for the payload in a |
| 40 |
content frame. |
| 41 |
|
| 42 |
:param data: The content body data from the frame |
| 43 |
|
| 44 |
""" |
| 45 |
self.value = data |