Bases: BaseSerializer
Converts string or string compatible types to bytes and vice versa.
Source code in repo/hololinked/hololinked/serializers/text.py
| class TextSerializer(BaseSerializer):
"""Converts string or string compatible types to bytes and vice versa."""
def __init__(self) -> None:
super().__init__()
self.type = None
def dumps(self, data: Any) -> bytes:
return str(data).encode("utf-8")
def loads(self, data: bytes) -> Any:
return data.decode("utf-8")
@property
def content_type(self) -> str:
return "text/plain"
|
Attributes
Functions
__init__
Source code in repo/hololinked/hololinked/serializers/text.py
| def __init__(self) -> None:
super().__init__()
self.type = None
|
dumps
dumps(data: Any) -> bytes
Source code in repo/hololinked/hololinked/serializers/text.py
| def dumps(self, data: Any) -> bytes:
return str(data).encode("utf-8")
|
loads
loads(data: bytes) -> Any
Source code in repo/hololinked/hololinked/serializers/text.py
| def loads(self, data: bytes) -> Any:
return data.decode("utf-8")
|