Skip to main content

EncodedBytes

A bytes type that is encoded and decoded using the specified encoder.

Attributes

AttributeTypeDescription
encodertype[[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

NameTypeDescription
encodertype[[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

NameTypeDescription
databytesThe data to decode.
_core_schema.ValidationInfoPydantic validation context, currently unused by this implementation.

Returns

TypeDescription
bytesThe decoded data.

encode()

@classmethod
def encode(
value: bytes
) - > bytes

Encode the data using the specified encoder.

Parameters

NameTypeDescription
valuebytesThe data to encode.

Returns

TypeDescription
bytesThe encoded data.