EncodedBytes
A bytes type that is encoded and decoded using the specified encoder.
Attributes
| Attribute | Type | Description |
|---|---|---|
| encoder | type[[EncoderProtocol](encoderprotocol.md?sid=pydantic_types_encoderprotocol)] | A class implementing the EncoderProtocol used to handle the transformation logic for encoding and decoding byte data. |
Constructor
Signature
def EncodedBytes(
encoder: type[[EncoderProtocol](encoderprotocol.md?sid=pydantic_types_encoderprotocol)]
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| encoder | type[[EncoderProtocol](encoderprotocol.md?sid=pydantic_types_encoderprotocol)] | The encoder class used for encoding and decoding the byte data. |
Methods
decode()
@classmethod
def decode(
data: bytes,
_: core_schema.ValidationInfo
) - > bytes
Decode the data using the specified encoder.
Parameters
| Name | Type | Description |
|---|---|---|
| data | bytes | The data to decode. |
| _ | core_schema.ValidationInfo | Pydantic validation context, currently unused by this implementation. |
Returns
| Type | Description |
|---|---|
bytes | The decoded data. |
encode()
@classmethod
def encode(
value: bytes
) - > bytes
Encode the data using the specified encoder.
Parameters
| Name | Type | Description |
|---|---|---|
| value | bytes | The data to encode. |
Returns
| Type | Description |
|---|---|
bytes | The encoded data. |