
    @'h                        d dl mZ d dlmZmZ  G d de      Z G d dee      Z G d de      Z	 	 	 	 dd	Z G d
 de      Z	y)    )annotations)AnyProtocolc                       e Zd ZdZddZddZy)UntypedSerializerProtocolz:Protocol for serialization and deserialization of objects.c                     y N selfobjs     f/home/kushmeetdev/Regenta/Chatbot/venv/lib/python3.12/site-packages/langgraph/checkpoint/serde/base.pydumpszUntypedSerializerProtocol.dumps	           c                     y r	   r
   r   datas     r   loadszUntypedSerializerProtocol.loads   r   r   Nr   r   returnbytesr   r   r   r   )__name__
__module____qualname____doc__r   r   r
   r   r   r   r      s    D+,r   r   c                       e Zd ZdZddZddZy)SerializerProtocolav  Protocol for serialization and deserialization of objects.

    - `dumps`: Serialize an object to bytes.
    - `dumps_typed`: Serialize an object to a tuple (type, bytes).
    - `loads`: Deserialize an object from bytes.
    - `loads_typed`: Deserialize an object from a tuple (type, bytes).

    Valid implementations include the `pickle`, `json` and `orjson` modules.
    c                     y r	   r
   r   s     r   dumps_typedzSerializerProtocol.dumps_typed   r   r   c                     y r	   r
   r   s     r   loads_typedzSerializerProtocol.loads_typed   r   r   Nr   r   r   tuple[str, bytes]r   r%   r   r   )r   r   r   r   r!   r#   r
   r   r   r   r      s     >>r   r   c                  4    e Zd ZddZddZd	dZd
dZddZy)SerializerCompatc                    || _         y r	   serde)r   r+   s     r   __init__zSerializerCompat.__init__   s	    
r   c                8    | j                   j                  |      S r	   )r+   r   r   s     r   r   zSerializerCompat.dumps"   s    zz$$r   c                8    | j                   j                  |      S r	   r+   r   r   s     r   r   zSerializerCompat.loads%   s    zz%%r   c                b    t        |      j                  | j                  j                  |      fS r	   )typer   r+   r   r   s     r   r!   zSerializerCompat.dumps_typed(   s&    Cy!!4::#3#3C#888r   c                >    | j                   j                  |d         S )N   r/   r   s     r   r#   zSerializerCompat.loads_typed+   s    zzQ((r   N)r+   r   r   Noner   r   r$   r&   )r   r   r   r,   r   r   r!   r#   r
   r   r   r(   r(      s    %&9)r   r(   c                L    t        | d      rt        | d      st        |       S | S )zmWrap serde old serde implementations in a class with loads_typed and dumps_typed for backwards compatibility.r#   r!   )hasattrr(   r*   s    r   maybe_add_typed_methodsr7   /   s'    
 5-(}0M&&Lr   c                       e Zd ZdZddZddZy)CipherProtocolz}Protocol for encryption and decryption of data.
    - `encrypt`: Encrypt plaintext.
    - `decrypt`: Decrypt ciphertext.
    c                     y)z=Encrypt plaintext. Returns a tuple (cipher name, ciphertext).Nr
   )r   	plaintexts     r   encryptzCipherProtocol.encrypt@       r   c                     y)z*Decrypt ciphertext. Returns the plaintext.Nr
   )r   
ciphername
ciphertexts      r   decryptzCipherProtocol.decryptD   r=   r   N)r;   r   r   r%   )r?   strr@   r   r   r   )r   r   r   r   r<   rA   r
   r   r   r9   r9   :   s    
r   r9   N)r+   z.SerializerProtocol | UntypedSerializerProtocolr   r   )

__future__r   typingr   r   r   r   r(   r7   r9   r
   r   r   <module>rE      sT    "  - -?2H ? )) )"9X r   