generated from pufereq/python-template
feat(message.py): add Message.from_bytes()
This commit is contained in:
@@ -89,6 +89,17 @@ class Message:
|
|||||||
"""
|
"""
|
||||||
return cls.from_dict(json.loads(data))
|
return cls.from_dict(json.loads(data))
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_bytes(cls, data: bytes) -> Message:
|
||||||
|
"""Create a Message from bytes.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
data (bytes): The bytes to create the message from.
|
||||||
|
Returns:
|
||||||
|
Message: The created message.
|
||||||
|
"""
|
||||||
|
return cls.from_json(data.decode("utf-8"))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def ack(cls) -> Message:
|
def ack(cls) -> Message:
|
||||||
"""Create an ACK message.
|
"""Create an ACK message.
|
||||||
|
|||||||
Reference in New Issue
Block a user