o
    U۷i                     @  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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
StructMetaasdictastupleforce_setattrreplace)get_class_annotations)	FieldInfor	   r   r   fieldsr   r   c                   C     t S N)__all__ r   r   E/home/ubuntu/vllm_env/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>7       zFieldInfo.<lambda>)default_factorydefaultc                   C  r   r   r   r   r   r   r   r   8   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   required:   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| }}nt t|trt| }}n|}t|d|}t |ts+tdt|}t|jt|j }g }t	|j|j
tf| |j D ](\}}}	t }
}t |	tr[|	j}n|	tura|	}
t|||| |
|d}|| qIt|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	TypeError_get_class_annotationslen__struct_fields____struct_defaults__zip__struct_encode_fields__r   _Factoryfactoryr   appendtuple)r+   objannotated_clsclshintsnposr   r   r   default_objr    r   r   r   r   r   r   @   s>   



r   N)r+   r,   r!   r-   )
__future__r   typingr    r   r   r   _corer   r8   r	   r
   r   r   r   r   _utilsr   r2   r   r   r   r   r   r   r   r   <module>   s    $	 