
    ԟf~                        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 Z G d	 d
e      ZddZy)    )annotations)Any   )	NODEFAULTStructfield)FactoryStructConfigasdictastuplereplaceforce_setattr)get_class_annotations)	FieldInfor
   r   r   fieldsr   r   c                     t         S N)__all__     J/var/www/cvtools/html/venv/lib/python3.12/site-packages/msgspec/structs.py__dir__r      s    Nr   c                  ~    e Zd ZU dZded<   ded<   ded<    ed       Zded	<    ed
       Zded<   edd       Z	y)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                     t         S r   r   r   r   r   <lambda>zFieldInfo.<lambda>6   s     r   )default_factorydefaultc                     t         S r   r   r   r   r   r    zFieldInfo.<lambda>7   s     r   r!   c                N    | j                   t        u xr | j                  t        u S )z1A helper for checking whether a field is required)r"   r   r!   )selfs    r   requiredzFieldInfo.required9   s#     ||y(NT-A-AY-NNr   N)returnbool)
__name__
__module____qualname____doc____annotations__r   r"   r!   propertyr&   r   r   r   r   r      sM    & I
I):;GS; 1BCOSCO Or   r   c                \   t        | t              rt        |       x}}n:| }t        | d|       }t        |t              rt	        |t              st        d      t        |      }t        |j                        t        |j                        z
  }g }t        |j                  |j                  t        f|z  |j                  z         D ]Y  \  }}}t        x}	}
t        |t              r|j                  }
n
|t        ur|}	t        ||||   |	|
      }|j!                  |       [ 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len__struct_fields____struct_defaults__zip__struct_encode_fields__r   _Factoryfactoryr   appendtuple)type_or_instanceannotated_clsclshintsnposr   r   r   default_objr"   r!   r   s               r   r   r   ?   s)    "F+"#344(&6FG3%*S&*AKLL"=1Es$$%C,C,C(DDDF*-$$	tc555+ &k;
 %.-/k8,)11O	)!G#t+
 	e%( =r   N)r?   zStruct | type[Struct]r'   ztuple[FieldInfo])
__future__r   typingr    r   r   r   _corer	   r;   r
   r   r   r   r   _utilsr   r5   r   r   r   r   r   r   r   <module>rJ      sA    "  & &  DO O@+r   