o
    Zh                     @   sN   d Z ddlZddlmZ ddlmZ dd ZG dd	 d	eeZeZd	d
gZ	dS )z0MQ Frame pure Python methods.    N)Frame   )AttributeSetterc                 C   s&   t j| | t jstd| d S )Nz6libzmq and pyzmq must be built with draft support for )zmqerrorZ_check_versionZ	DRAFT_APIRuntimeError)vfeature r
   F/var/www/html/lang_env/lib/python3.10/site-packages/zmq/sugar/frame.py_draft   s   r   c                   @   sT   e Zd ZdZdd Zdd Zedd Zejdd Zed	d
 Z	e	jdd
 Z	dS )r   au  
    A zmq message Frame class for non-copying send/recvs and access to message properties.

    A ``zmq.Frame`` wraps an underlying ``zmq_msg_t``.

    Message *properties* can be accessed by treating a Frame like a dictionary (``frame["User-Id"]``).

    .. versionadded:: 14.4, libzmq 4

        Frames created by ``recv(copy=False)`` can be used to access message properties and attributes,
        such as the CURVE User-Id.

        For example::

            frames = socket.recv_multipart(copy=False)
            user_id = frames[0]["User-Id"]

    This class is used if you want to do non-copying send and recvs.
    When you pass a chunk of bytes to this class, e.g. ``Frame(buf)``, the
    ref-count of `buf` is increased by two: once because the Frame saves `buf` as
    an instance attribute and another because a ZMQ message is created that
    points to the buffer of `buf`. This second ref-count increase makes sure
    that `buf` lives until all messages that use it have been sent.
    Once 0MQ sends all the messages and it doesn't need the buffer of ``buf``,
    0MQ will call ``Py_DECREF(s)``.

    Parameters
    ----------

    data : object, optional
        any object that provides the buffer interface will be used to
        construct the 0MQ message data.
    track : bool
        whether a MessageTracker_ should be created to track this object.
        Tracking a message has a cost at creation, because it creates a threadsafe
        Event object.
    copy : bool
        default: use copy_threshold
        Whether to create a copy of the data to pass to libzmq
        or share the memory with libzmq.
        If unspecified, copy_threshold is used.
    copy_threshold: int
        default: :const:`zmq.COPY_THRESHOLD`
        If copy is unspecified, messages smaller than this many bytes
        will be copied and messages larger than this will be shared with libzmq.
    c                 C   s
   |  |S )N)get)selfkeyr
   r
   r   __getitem__D   s   
zFrame.__getitem__c                 C   s   t | }d}|dkrBtt| dd }|dkrd}|d }n|dkr*d}|d	 }n|d
kr5d}|d
 }nd}|}d|d| }n| j}| jj}|dkrOd}d| d| jj d|| dS )z#Return the str form of the message.    N   g    eAGBi   MBg    .Ag     @@kBBz...z.0fzzmq.sugar.framer   <.(z)>)lenbytes
memoryview	__class__
__module____name__)r   nbytesZ
msg_suffixZ	msg_bytesunitn_moduler
   r
   r   __repr__H   s*   


 zFrame.__repr__c                 C      t dd | dS )zThe RADIO-DISH group of the message.

        Requires libzmq >= 4.2 and pyzmq built with draft APIs enabled.

        .. versionadded:: 17
              
RADIO-DISHgroupr   r   r   r
   r
   r   r+   c      

zFrame.groupc                 C      t dd | d| d S )Nr'   r*   r+   r   set)r   r+   r
   r
   r   r+   n      
c                 C   r&   )zThe CLIENT-SERVER routing id of the message.

        Requires libzmq >= 4.2 and pyzmq built with draft APIs enabled.

        .. versionadded:: 17
        r'   CLIENT-SERVER
routing_idr,   r-   r
   r
   r   r4   s   r.   zFrame.routing_idc                 C   r/   )Nr'   r3   r4   r0   )r   r4   r
   r
   r   r4   ~   r2   N)
r    r   __qualname____doc__r   r%   propertyr+   setterr4   r
   r
   r
   r   r      s    /




r   Message)
r6   r   Zzmq.backendr   Z	FrameBaseZ	attrsettrr   r   r9   __all__r
   r
   r
   r   <module>   s    q