o
    ɭRh                     @   st   d dl mZ d dlmZmZmZmZmZ d dlm	Z	 d dl
Z
edddZG dd	 d	ee ZG d
d dee ZdS )    )abstractmethod)AnyDictGenericProtocolTypeVar)SelfNTT)	covariantc                   @   sh   e Zd ZdZdefddZededefddZde	ee
f fdd	Zed
e	ee
f defddZdS )JSONSerializablez>A generic interface for objects that can be serialized to JSONreturnc                 C      dS )Serializes the object to JSONN selfr   r   P/home/air/sanwanet/backup_V2/venv/lib/python3.10/site-packages/chromadb/serde.pyto_json_str      zJSONSerializable.to_json_strjson_strc                 C   r   z!Deserializes the object from JSONNr   )clsr   r   r   r   from_json_str      zJSONSerializable.from_json_strc                 C   r   )5Serializes the object to a JSON compatible dictionaryNr   r   r   r   r   to_json   r   zJSONSerializable.to_jsonjson_mapc                 C   r   r   r   r   r   r   r   r   	from_json   r   zJSONSerializable.from_jsonN)__name__
__module____qualname____doc__strr   classmethodr   r   r   r   r   r   r   r   r   r   r   	   s     r   c                   @   sh   e Zd ZdZdefddZdeeef fddZe	defddZ
ee	d	eeef defd
dZdS )BaseModelJSONSerializablezCA mixin for BaseModels that allows a class to be serialized to JSONr   c                 C   s   |   S )r   )model_dump_jsonr   r   r   r   r   "   s   z%BaseModelJSONSerializable.to_json_strc                 C   s   t |  S )r   )jsonloadsr&   r   r   r   r   r   &   s   z!BaseModelJSONSerializable.to_jsonc                 C   r   )zDAbstract method that should be implemented to dump the model to JSONNr   r   r   r   r   r&   *   r   z)BaseModelJSONSerializable.model_dump_jsonr   c                 C   r   r   r   r   r   r   r   r   /   s   z#BaseModelJSONSerializable.from_jsonN)r   r    r!   r"   r#   r   r   r   r   r   r&   r$   r	   r   r   r   r   r   r%      s    "r%   )abcr   typingr   r   r   r   r   typing_extensionsr   r'   r	   r   r%   r   r   r   r   <module>   s    