
    9i                        d dl mZ d dlmZmZmZ  G d de      Ze G d de             Z G d de      Z	 	 	 	 dd	Z	 G d
 de      Z
y)    )annotations)AnyProtocolruntime_checkablec                       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     i/var/www/html/backtest/airagagent/rag_env/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)SerializerProtocolaz  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                  $    e Z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                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   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'      s    9)r   r'   c                <    t        | t              st        |       S | S )zmWrap serde old serde implementations in a class with loads_typed and dumps_typed for backwards compatibility.)
isinstancer   r'   r)   s    r   maybe_add_typed_methodsr3   *   s    
 e/0&&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.decrypt?   r9   r   N)r7   r   r   r$   )r;   strr<   r   r   r   )r   r   r   r   r8   r=   r   r   r   r5   r5   5   s    
r   r5   N)r*   z.SerializerProtocol | UntypedSerializerProtocolr   r   )
__future__r   typingr   r   r   r   r   r'   r3   r5   r   r   r   <module>rA      sc    " 3 3- - ? ? ? )) )9X r   