pynenc.serializer.base_serializer#

Module Contents#

Classes#

BaseSerializer

BaseSerializer is an abstract class that defines a standard interface for serialization and deserialization.

API#

class pynenc.serializer.base_serializer.BaseSerializer[source]#

Bases: abc.ABC

BaseSerializer is an abstract class that defines a standard interface for serialization and deserialization.

It’s designed to be extended for specific serialization formats like JSON, Pickle, or custom formats as needed. Implementers of this class need to provide concrete methods for serialize and deserialize operations.

abstract static serialize(obj: Any) str[source]#

Serializes the given object into a string representation.

This method needs to be implemented by subclasses to convert various data types into a serialized string format. It’s useful for storing or transmitting data, especially in distributed systems.

Parameters:

obj – The object to be serialized.

Returns:

A string representation of the serialized object.

abstract static deserialize(obj: str) Any[source]#

Deserializes the given string back into an object.

This method should be implemented by subclasses to reconstruct an object from its serialized string form. It’s particularly important for retrieving or receiving data in its original form.

Parameters:

obj – The string representation of the object to be deserialized.

Returns:

The deserialized object.