o
    ;h~                     @  s   d dl mZ d dlmZ ddlmZmZmZ ddlm	Z
mZmZmZmZmZ ddlmZ dZdd	 ZG d
d deZdddZdS )    )annotations)Any   )	NODEFAULTStructfield)FactoryStructConfigasdictastuplereplaceforce_setattr)get_class_annotations)	FieldInfor	   r
   r   fieldsr   r   c                   C     t S N)__all__ r   r   B/var/www/html/venv/lib/python3.10/site-packages/msgspec/structs.py__dir__   s   r   c                   @  sd   e Zd ZU dZded< ded< ded< edd d	Zded
< edd d	Zded< edddZ	dS )r   a  A record describing a field in a struct type.

    Parameters
    ----------
    name: str
        The field name as seen by Python code (e.g. ``field_one``).
    encode_name: str
        The name used when encoding/decoding the field. This may differ if
        the field is renamed (e.g. ``fieldOne``).
    type: Any
        The full field type annotation.
    default: Any, optional
        A default value for the field. Will be `NODEFAULT` if no default value
        is set.
    default_factory: Any, optional
        A callable that creates a default value for the field. Will be
        `NODEFAULT` if no ``default_factory`` is set.
    strnameencode_namer   typec                   C  r   r   r   r   r   r   r   <lambda>6       zFieldInfo.<lambda>)default_factorydefaultc                   C  r   r   r   r   r   r   r   r   7   r   r   returnboolc                 C  s   | j tu o	| jtu S )z1A helper for checking whether a field is required)r   r   r   )selfr   r   r   required9   s   zFieldInfo.requiredN)r    r!   )
__name__
__module____qualname____doc____annotations__r   r   r   propertyr#   r   r   r   r   r      s   
 r   type_or_instanceStruct | type[Struct]r    tuple[FieldInfo]c                 C  s   t | trt|  }}n| }t| d| }t |trt|ts"tdt|}t|jt|j	 }g }t
|j|jtf| |j	 D ](\}}}t }	}
t |trR|j}
n|turX|}	t|||| |	|
d}|| q@t|S )zGet information about the fields in a Struct.

    Parameters
    ----------
    type_or_instance:
        A struct type or instance.

    Returns
    -------
    tuple[FieldInfo]
    
__origin__z-Must be called with a struct type or instance)r   r   r   r   r   )
isinstancer   r   getattr
issubclass	TypeError_get_class_annotationslenZ__struct_fields__Z__struct_defaults__zipZ__struct_encode_fields__r   _Factoryfactoryr   appendtuple)r*   Zannotated_clsclshintsZnposr   r   r   Zdefault_objr   r   r   r   r   r   r   ?   s8   

r   N)r*   r+   r    r,   )
__future__r   typingr    r   r   r   Z_corer   r5   r	   r
   r   r   r   Z_utilsr   r2   r   r   r   r   r   r   r   r   <module>   s      