
    5iq                        d Z ddlZddlmZ ddlmZ ddlZddlmZ  G d de      Z	d Z
d	 Z G d
 de      Z G d de      Z G d de      Z G d de      Zd Z G d de      Z G d de      Z G d d      Z G d de      Z G d de      Z G d d      Z G d d e      Z G d! d"e      Zd# Zd$ Z G d% d&e      Z G d' d(e      Zy))z
I/O library for `awscrt`.

All networking in `awscrt` is asynchronous.
Long-running event-loop threads are used for concurrency.
    N)NativeResource)IntEnum)Unionc                   (    e Zd ZdZdZdZdZdZdZdZ	y)	LogLevelr                     N)
__name__
__module____qualname__NoLogsFatalErrorWarnInfoDebugTrace     k/home/marpiech/ifpan-abm-pgxpred/analysis/marpiech-gwas-test/venv/lib/python3.12/site-packages/awscrt/io.pyr   r      s%    FEEDDEEr   r   c                 @    | J |J t        j                  | |       y)a  Initialize logging in `awscrt`.

    Args:
        log_level (LogLevel): Display messages of this importance and higher.
        file_name (str): Logging destination. To write to stdout or stderr pass
            'stdout' or 'stderr' as strings. Otherwise, a file path is assumed.
    N)_awscrtinit_logging)	log_level	file_names     r   r   r      s,           I.r   c                 6    | J t        j                  |        y)zChange the log level of `awscrt`. init_logging() must have been called
    before using this function or else an exception will be raised.

    Args:
        log_level (LogLevel): Display messages of this importance and higher.
    N)r   set_log_level)r   s    r   r!   r!   *   s        )$r   c                   n     e Zd ZdZdZ ej                         ZdZd fd	Z	e
d        Ze
d        Z xZS )EventLoopGroupaa  A collection of event-loops.

    An event-loop is a thread for doing async work, such as I/O. Classes that
    need to do async work will ask the EventLoopGroup for an event-loop to use.

    Args:
        num_threads (Optional[int]): Maximum number of event-loops to create.
            If unspecified, one is created for each processor on the machine.

        cpu_group (Optional[int]): Optional processor group to which all
            threads will be pinned. Useful for systems with non-uniform
            memory access (NUMA) nodes. If specified, the number of threads
            will be capped at the number of processors in the group.

    Attributes:
        shutdown_event (threading.Event): Signals when EventLoopGroup's threads
            have all finished shutting down. Shutdown begins when the
            EventLoopGroup object is destroyed.
    Nshutdown_eventc                     t         |           |d}|d}d}nd}t        j                         fd}| _        t        j                  ||||      | _        y )Nr   FTc                  &     j                          y Nsetr$   s   r   on_shutdownz,EventLoopGroup.__init__.<locals>.on_shutdown^        r   )super__init__	threadingEventr$   r   event_loop_group_new_binding)selfnum_threads	cpu_group	is_pinnedr+   r$   	__class__s        @r   r.   zEventLoopGroup.__init__O   sb    KIII"*	! -44[)YXcdr   c                      t         j                  5  t         j                  t               t         _        t         j                  cd d d        S # 1 sw Y   y xY wr'   r#   _static_event_loop_group_lock_static_event_loop_groupr   r   r   get_or_create_static_defaultz+EventLoopGroup.get_or_create_static_defaultd   s@    99 	;66>:H:J7!::	; 	; 	;s   3AAc                  d    t         j                  5  d t         _        d d d        y # 1 sw Y   y xY wr'   r9   r   r   r   release_static_defaultz%EventLoopGroup.release_static_defaultk   s(    99 	;6:N3	; 	; 	;   &/NN)r   r   r   __doc__r;   r/   Lockr:   	__slots__r.   staticmethodr<   r>   __classcell__r7   s   @r   r#   r#   6   sR    (  $$2INN$4!!Ie* ; ; ; ;r   r#   c                       e Zd ZdZdZy)HostResolverBasezDNS host resolver.r   N)r   r   r   rA   rC   r   r   r   rH   rH   q   s
    Ir   rH   c                   n     e Zd ZdZdZ ej                         ZdZd fd	Z	e
d        Ze
d        Z xZS )DefaultHostResolverzDefault DNS host resolver.

    Args:
        event_loop_group (EventLoopGroup): EventLoopGroup to use.
        max_hosts(int): Max host names to cache.
    Nr   c                 |    t        |t              sJ t        |           t	        j
                  ||      | _        y r'   )
isinstancer#   r-   r.   r   host_resolver_new_defaultr2   )r3   event_loop_group	max_hostsr7   s      r   r.   zDefaultHostResolver.__init__   s4    *N;;;99)EUVr   c                      t         j                  5  t         j                  &t        t        j	                               t         _        t         j                  cd d d        S # 1 sw Y   y xY wr'   )rJ   _static_host_resolver_lock_static_host_resolverr#   r<   r   r   r   r<   z0DefaultHostResolver.get_or_create_static_default   sP     ;; 	="88@<O"??A=C#9&<<		= 	= 	=s   AA!!A*c                  d    t         j                  5  d t         _        d d d        y # 1 sw Y   y xY wr'   )rJ   rQ   rR   r   r   r   r>   z*DefaultHostResolver.release_static_default   s)     ;; 	=8<5	= 	= 	=r?   )   )r   r   r   rA   rR   r/   rB   rQ   rC   r.   rD   r<   r>   rE   rF   s   @r   rJ   rJ   v   sR     !!/!1IW = = = =r   rJ   c                   l     e Zd ZdZdZ ej                         ZdZ fdZ	e
d        Ze
d        Z xZS )ClientBootstrapa  Handles creation and setup of client socket connections.

    Args:
        event_loop_group (EventLoopGroup): EventLoopGroup to use.
        host_resolver (HostResolverBase): DNS host resolver to use.

    Attributes:
        shutdown_event (threading.Event): Signals when the ClientBootstrap's
            internal resources finish shutting down.
            Shutdown begins when the ClientBootstrap object is destroyed.
    Nr$   c                     t        |t              sJ t        |t              sJ t        |           t        j                         fd}| _        t        j                  |||      | _
        y )Nc                  &     j                          y r'   r(   r*   s   r   r+   z-ClientBootstrap.__init__.<locals>.on_shutdown   r,   r   )rL   r#   rH   r-   r.   r/   r0   r$   r   client_bootstrap_newr2   )r3   rN   host_resolverr+   r$   r7   s       @r   r.   zClientBootstrap.__init__   sc    *N;;;-)9:::"*	! -445E}Vabr   c                      t         j                  5  t         j                  9t        t        j	                         t
        j	                               t         _        t         j                  cd d d        S # 1 sw Y   y xY wr'   )rV   _static_client_bootstrap_lock_static_client_bootstrapr#   r<   rJ   r   r   r   r<   z,ClientBootstrap.get_or_create_static_default   s]    :: 	<77?;J"??A'DDF<H8 #;;	< 	< 	<s   AA44A=c                  d    t         j                  5  d t         _        d d d        y # 1 sw Y   y xY wr'   )rV   r\   r]   r   r   r   r>   z&ClientBootstrap.release_static_default   s(    :: 	<7;O4	< 	< 	<r?   )r   r   r   rA   r]   r/   rB   r\   rC   r.   rD   r<   r>   rE   rF   s   @r   rV   rV      sR    
  $$2INN$4!!Ic < < < <r   rV   c                 l    t        | d      5 }|j                         }d d d        |S # 1 sw Y   S xY w)Nrb)mode)openread)filepathfhcontentss      r   _read_binary_filerg      s3    	hT	" b779OOs   )3c                       e Zd ZdZdZdZy)SocketDomainr   r   r	   N)r   r   r   IPv4IPv6Localr   r   r   ri   ri      s    DDEr   ri   c                       e Zd ZdZ	 dZy)
SocketTyper   r   N)r   r   r   StreamDGramr   r   r   rn   rn      s    FC E<r   rn   c                       e Zd ZdZdZd Zy)SocketOptionsa[  Socket options.

    Attributes:
        domain (SocketDomain): Socket domain.
        type (SocketType): Socket type.
        connect_timeout_ms (int): Connection timeout, in milliseconds.
        keep_alive (bool): If set True, periodically transmit keepalive messages
            for detecting a disconnected peer.
        keep_alive_timeout_secs (int): Duration, in seconds, between keepalive
            transmissions in idle condition. If 0, then a default value is used.
        keep_alive_interval_secs (int): Duration, in seconds, between keepalive
            retransmissions, if acknowledgement of previous keepalive transmission
            is not received. If 0, then a default value is used.
        keep_alive_max_probes (int): If set, sets the number of keepalive probes
            allowed to fail before a connection is considered lost.
    )domaintypeconnect_timeout_ms
keep_alivekeep_alive_timeout_secskeep_alive_interval_secskeep_alive_max_probesc                     | j                   D ]  }t        | |d         t        j                  | _        t
        j                  | _        d| _        d| _	        d| _
        d| _        d| _        y )Ni  Fr   )rC   setattrri   rk   rs   rn   ro   rt   ru   rv   rx   rw   ry   r3   slots     r   r.   zSocketOptions.__init__   sd    NN 	&DD$%	& #''%%	"&()%'($%&"r   N)r   r   r   rA   rC   r.   r   r   r   rr   rr      s    "I

'r   rr   c                   $    e Zd ZdZdZdZdZdZdZy)
TlsVersionr   r   r	   r
   r      N)	r   r   r   SSLv3TLSv1TLSv1_1TLSv1_2TLSv1_3DEFAULTr   r   r   r   r      s     EEGGGGr   r   c                   .    e Zd ZdZdZ	 dZ	 dZ	 dZ	 d Zy)TlsCipherPrefa*  TLS Cipher Preference.

       Each TlsCipherPref represents an ordered list of TLS Ciphers to use when negotiating a TLS Connection. At
       present, the ability to configure arbitrary orderings of TLS Ciphers is not allowed, and only a curated list of
       vetted TlsCipherPref's are exposed.r   r      	   c                 @    t        j                  | j                        S )zbReturn whether this Cipher Preference is available in the underlying platform's TLS implementation)r   is_tls_cipher_supportedvaluer3   s    r   is_supportedzTlsCipherPref.is_supported(  s    ..tzz::r   N)	r   r   r   rA   r   PQ_TLSv1_0_2021_05
PQ_DEFAULTTLSv1_2_2025_07r   r   r   r   r   r   	  s;    . Gy 	- JkOp;r   r   c                       e Zd ZdZdZd Zed        Zed        Zedddddddd	d
e	e
df   dede
de
de
fd       Zed        Zed        Zed        Zed        Zed        ZddZd Zy)TlsContextOptionsa5  Options to create a TLS context.

    The static `TlsContextOptions.create_X()` methods provide common TLS configurations.
    A default-initialized TlsContextOptions has `verify_peer` set True.

    Attributes:
        min_tls_ver (TlsVersion): Minimum TLS version to use.
            System defaults are used by default.
        cipher_pref (TlsCipherPref): The TLS Cipher Preference to use. System defaults are used by default.
        verify_peer (bool): Whether to validate the peer's x.509 certificate.
        alpn_list (Optional[List[str]]): If set, names to use in Application Layer
            Protocol Negotiation (ALPN). ALPN is not supported on all systems,
            see :meth:`is_alpn_available()`. This can be customized per connection,
            via :meth:`TlsConnectionOptions.set_alpn_list()`.
    )min_tls_ver
ca_dirpath	ca_buffercipher_pref	alpn_listcertificate_bufferprivate_key_bufferpkcs12_filepathpkcs12_passwordverify_peer_pkcs11_lib_pkcs11_user_pin_pkcs11_slot_id_pkcs11_token_label_pkcs11_private_key_label_pkcs11_cert_file_path_pkcs11_cert_file_contents_windows_cert_store_pathc                     | j                   D ]  }t        | |d         t        j                  | _        t
        j                  | _        d| _        y )NT)rC   r{   r   r   r   r   r   r   r|   s     r   r.   zTlsContextOptions.__init__R  sG    NN 	&DD$%	& &--(00r   c                     t        | t              sJ t        |t              sJ t        |       }t        |      }t        j	                  ||      S )a  
        Create options configured for use with mutual TLS in client mode.

        Both files are treated as PKCS #7 PEM armored.
        They are loaded from disk and stored in buffers internally.

        Args:
            cert_filepath (str): Path to certificate file.
            pk_filepath (str): Path to private key file.

        Returns:
            TlsContextOptions:
        )rL   strrg   r   create_client_with_mtlscert_filepathpk_filepathcert_buffer
key_buffers       r   !create_client_with_mtls_from_pathz3TlsContextOptions.create_client_with_mtls_from_path[  sK      ----+s+++'6&{3
 88jQQr   c                 ~    t        | t              sJ t        |t              sJ t               }| |_        ||_        |S )a9  
        Create options configured for use with mutual TLS in client mode.

        Both buffers are treated as PKCS #7 PEM armored.

        Args:
            cert_buffer (bytes): Certificate contents
            key_buffer (bytes): Private key contents.

        Returns:
            TlsContextOptions:
        )rL   bytesr   r   r   r   r   opts      r   r   z)TlsContextOptions.create_client_with_mtlss  sA     +u---*e,,,!!,!+
r   N)slot_idtoken_labelprivate_key_labelcert_file_pathcert_file_contents
pkcs11_lib	Pkcs11Libuser_pinr   r   r   r   c                 h   t        | t              sJ t        |t              s|J t        |t              s|J t        |t              s|J t        |t              s|J t        |t              s|J t	               }| |_        ||_        ||_        ||_        ||_	        ||_
        ||_        |S )aC  
        Create options configured for use with mutual TLS in client mode,
        using a PKCS#11 library for private key operations.

        NOTE: This configuration only works on Unix devices.

        Keyword Args:
            pkcs11_lib (Pkcs11Lib): Use this PKCS#11 library

            user_pin (str): User PIN, for logging into the PKCS#11 token.
                Pass `None` to log into a token with a "protected authentication path".

            slot_id (Optional[int]): ID of slot containing PKCS#11 token.
                If not specified, the token will be chosen based on other criteria (such as token label).

            token_label (Optional[str]): Label of the PKCS#11 token to use.
                If not specified, the token will be chosen based on other criteria (such as slot ID).

            private_key_label (Optional[str]): Label of private key object on PKCS#11 token.
                If not specified, the key will be chosen based on other criteria
                (such as being the only available private key on the token).

            cert_file_path (Optional[str]): Use this X.509 certificate (path to file on disk).
                The certificate must be PEM-formatted. The certificate may be
                specified by other means instead (ex: `cert_file_contents`)

            cert_file_contents (Optional[Union[str, bytes, bytearray]]):
                Use this X.509 certificate (contents in memory).
                The certificate must be PEM-formatted. The certificate may be
                specified by other means instead (ex: `cert_file_path`)
        )rL   r   r   intr   r   r   r   r   r   r   r   )r   r   r   r   r   r   r   r   s           r   create_client_with_mtls_pkcs11z0TlsContextOptions.create_client_with_mtls_pkcs11  s    R *i000(C(H,<<<'3'7?::+s+{/BBB+S15F5NNN.#..2HHH  !$'%"-(9%%3");&
r   c                 ~    t        | t              sJ t        |t              sJ t               }| |_        ||_        |S )a  
        Create options configured for use with mutual TLS in client mode.

        NOTE: This configuration only works on Apple devices.

        Args:
            pkcs12_filepath (str): Path to PKCS #12 file.
                The file is loaded from disk and stored internally.
            pkcs12_password (str): Password to PKCS #12 file.

        Returns:
            TlsContextOptions:
        )rL   r   r   r   r   r   r   r   s      r   create_client_with_mtls_pkcs12z0TlsContextOptions.create_client_with_mtls_pkcs12  sA      /3////3///!--
r   c                 L    t        | t              sJ t               }| |_        |S )a  
        Create options configured for use with mutual TLS in client mode,
        using a certificate in a Windows certificate store.

        NOTE: This configuration only works on Windows devices.

        Args:
            cert_path (str): Path to certificate in a Windows certificate store.
                The path must use backslashes and end with the certificate's thumbprint.
                Example: ``CurrentUser\MY\A11F8A9B5DF5B98BA3508FBCA575D09570E0D2C6``

        Returns:
            TlsContextOptions
        )rL   r   r   r   )	cert_pathr   s     r   /create_client_with_mtls_windows_cert_store_pathzATlsContextOptions.create_client_with_mtls_windows_cert_store_path  s)      )S)))!'0$
r   c                     t        | t              sJ t        |t              sJ t        |       }t        |      }t        j	                  ||      S )as  
        Create options configured for use in server mode.

        Both files are treated as PKCS #7 PEM armored.
        They are loaded from disk and stored in buffers internally.

        Args:
            cert_filepath (str): Path to certificate file.
            pk_filepath (str): Path to private key file.

        Returns:
            TlsContextOptions:
        )rL   r   rg   r   create_serverr   s       r   create_server_from_pathz)TlsContextOptions.create_server_from_path  sK      ----+s+++'6&{3
 ..{JGGr   c                     t        | t              sJ t        |t              sJ t               }| |_        ||_        d|_        |S )a*  
        Create options configured for use in server mode.

        Both buffers are treated as PKCS #7 PEM armored.

        Args:
            cert_buffer (bytes): Certificate contents.
            key_buffer (bytes): Private key contents.

        Returns:
            TlsContextOptions:
        F)rL   r   r   r   r   r   r   s      r   r   zTlsContextOptions.create_server
  sH     +u---*e,,,!!,!+
r   c                     t        | t              sJ t        |t              sJ t               }| |_        ||_        d|_        |S )a:  
        Create options configured for use in server mode.

        NOTE: This configuration only works on Apple devices.

        Args:
            pkcs12_filepath (str): Path to PKCS #12 file.
            pkcs12_password (str): Password to PKCS #12 file.

        Returns:
            TlsContextOptions:
        F)rL   r   r   r   r   r   r   s      r   create_server_pkcs12z&TlsContextOptions.create_server_pkcs12!  sH     /3////3///!--
r   c                     t        |t              s|J t        |t              s|J |rt        |      }| j                  |       || _        y)at  Override default trust store.

        Args:
            ca_dirpath (Optional[str]): Path to directory containing
                trusted certificates, which will overrides the default trust store.
                Only supported on Unix.
            ca_filepath(Optional[str]): Path to file containing PEM armored chain
                of trusted CA certificates.
        N)rL   r   rg   override_default_trust_storer   )r3   r   ca_filepathr   s       r   &override_default_trust_store_from_pathz8TlsContextOptions.override_default_trust_store_from_path9  sP     *c*j.@@@+s+{/BBB)+6I--i8$r   c                 6    t        |t              sJ || _        y)zOverride default trust store.

        Args:
            rootca_buffer (bytes): PEM armored chain of trusted CA certificates.
        N)rL   r   r   )r3   rootca_buffers     r   r   z.TlsContextOptions.override_default_trust_storeM  s     -///&r   r@   )r   r   r   rA   rC   r.   rD   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   -  s   I*  R R.  ,  7;:>@D=A:>83>816sDy1A8 148 58	8
 ;>8 8;8 8t  .  ( H H.  ,  .%('r   r   c                   ,     e Zd ZdZdZ fdZd Z xZS )ClientTlsContextzClient TLS context.

    A context is expensive, but can be used for the lifetime of the application
    by all outgoing connections that wish to use the same TLS configuration.

    Args:
        options (TlsContextOptions): Configuration options.
    r   c                 >   t        |t              sJ t        |           t	        j
                  |j                  j                  |j                  j                  |j                  |j                  t        |j                        |j                  |j                  |j                  |j                   |j"                  |j$                  |j&                  |j(                  |j*                  |j,                  |j.                  |j0                  |j2                        | _        y r'   )rL   r   r-   r.   r   client_tls_ctx_newr   r   r   r   r   _alpn_list_to_strr   r   r   r   r   r   r   r   r   r   r   r   r   r   r2   )r3   optionsr7   s     r   r.   zClientTlsContext.__init__c  s    '#455522%%%%g//0&&&&####$$##''--**..,,%
r   c                     t        |       S )zCreate a :class:`TlsConnectionOptions` that makes use of this TLS context.

        Returns:
                TlsConnectionOptions:
        )TlsConnectionOptionsr   s    r   new_connection_optionsz'ClientTlsContext.new_connection_options|  s     $D))r   )r   r   r   rA   rC   r.   r   rE   rF   s   @r   r   r   X  s     I
2*r   r   c                   2     e Zd ZdZdZ fdZd Zd Z xZS )r   a6  Connection-specific TLS options.

    Note that, while a TLS context is an expensive object, a :class:`TlsConnectionOptions` is cheap.

    Args:
        tls_ctx (ClientTlsContext): TLS context. A context can be shared by many connections.

    Attributes:
        tls_ctx (ClientTlsContext): TLS context.
    tls_ctxc                     t        |t              sJ t        |           || _        t        j                  |      | _        y r'   )rL   r   r-   r.   r   r   $tls_connections_options_new_from_ctxr2   )r3   r   r7   s     r   r.   zTlsConnectionOptions.__init__  s8    '#3444DDWMr   c                 B    t        j                  | t        |             y)aG  Set names to use in Application Layer Protocol Negotiation (ALPN).

        This overrides any ALPN list on the TLS context, see :attr:`TlsContextOptions.alpn_list`.
        ALPN is not supported on all systems, see :meth:`is_alpn_available()`.

        Args:
            alpn_list (List[str]): List of protocol names.
        N)r   $tls_connection_options_set_alpn_listr   )r3   r   s     r   set_alpn_listz"TlsConnectionOptions.set_alpn_list  s     	44T;LY;WXr   c                 0    t        j                  | |       y)zSet server name.

        Sets name for TLS Server Name Indication (SNI).
        Name is also used for x.509 validation.

        Args:
            server_name (str): Server name.
        N)r   &tls_connection_options_set_server_name)r3   server_names     r   set_server_namez$TlsConnectionOptions.set_server_name  s     	66t[Ir   )	r   r   r   rA   rC   r.   r   r   rE   rF   s   @r   r   r     s!    	 IN	Y	Jr   r   c                 N    | r#t        | t              rJ dj                  |       S y)ze
    Transform ['h2', 'http/1.1'] -> "h2;http/1.1"
    None is returned if list is None or empty
    ;N)rL   r   join)r   s    r   r   r     s)    
 i---xx	""r   c                  *    t        j                         S )z^Returns True if Application Layer Protocol Negotiation (ALPN)
    is supported on this system.)r   is_alpn_availabler   r   r   r   r     s     $$&&r   c                   D     e Zd ZdZdZ fdZd Zd Zedd       Z	 xZ
S )InputStreamzInputStream allows `awscrt` native code to read from Python binary I/O classes.

    Args:
        stream (io.IOBase): Python binary I/O stream to wrap.
    _streamc                     t        t        |dd             st        d      t        |t              rJ t
        |           || _        t        j                  |       | _
        y )Nrc   zI/O stream type expected)callablegetattr	TypeErrorrL   r   r-   r.   r   r   input_stream_newr2   )r3   streamr7   s     r   r.   zInputStream.__init__  sV     56677fk222006r   c                    	 t        | j                  d      r| j                  j                  |      S t        | j                  d      r| j                  j                  |      S t        | j                  d      r%| j                  j	                  t        |            }n$| j                  j                  t        |            }t        |      }||d | |S # t        $ r Y y w xY w)N	readinto1readintoread1)hasattrr   r   r   r   lenrc   BlockingIOError)r3   mdatans       r   _read_into_memoryviewz!InputStream._read_into_memoryview  s    	t||[1||--a00t||Z0||,,Q//t||W-||))#a&1||((Q0D	AAbqEH 		s   0C 0C $A0C 	C! C!c                 :    | j                   j                  ||      S r'   )r   seek)r3   offsetwhences      r   _seekzInputStream._seek  s    ||  00r   c                 @    ||ryt        |t              r|S  | |      S )ad  
        Given some stream type, returns an :class:`InputStream`.

        Args:
            stream (Union[io.IOBase, InputStream, None]): Binary I/O stream to wrap.
            allow_none (bool): Whether to allow `stream` to be None.
                If False (default), and `stream` is None, an exception is raised.

        Returns:
            Union[InputStream, None]: If `stream` is already an :class:`InputStream`, it is returned.
            Otherwise, an :class:`InputStream` which wraps the `stream` is returned.
            If `allow_none` is True, and `stream` is None, then None is returned.
        N)rL   r   )clsr   
allow_nones      r   wrapzInputStream.wrap  s'     >jfk*M6{r   )F)r   r   r   rA   rC   r.   r   r  classmethodr  rE   rF   s   @r   r   r     s2    
 I	7(1  r   r   c                   H     e Zd ZdZ G d de      Zdddedef fdZ xZS )	r   a  
    Handle to a loaded PKCS#11 library.

    For most use cases, a single instance of :class:`Pkcs11Lib` should be used for the
    lifetime of your application.

    Keyword Args:
        file (str): Path to PKCS#11 library.
        behavior (Optional[InitializeFinalizeBehavior]):
            Specifies how `C_Initialize()` and `C_Finalize()` will be called
            on the PKCS#11 library (default is :attr:`InitializeFinalizeBehavior.DEFAULT`)
    c                        e Zd ZdZdZ	 dZ	 dZy)$Pkcs11Lib.InitializeFinalizeBehaviorz~
        An enumeration.

        Controls how `C_Initialize()` and `C_Finalize()` are called on the PKCS#11 library.
        r   r   r	   N)r   r   r   rA   r   OMITSTRICTr   r   r   InitializeFinalizeBehaviorr    s+    	 	 	 	r   r  N)behaviorfiler  c                    t         |           |t        j                  j                  }t        j                  ||      | _        y r'   )r-   r.   r   r  r   r   pkcs11_lib_newr2   )r3   r  r  r7   s      r   r.   zPkcs11Lib.__init__2  s9     ;;CCH..tX>r   )	r   r   r   rA   r   r  r   r.   rE   rF   s   @r   r   r     s5     W  D MQ ? ?/I ? ?r   r   )rA   r   awscrtr   enumr   r/   typingr   r   r   r!   r#   rH   rJ   rV   rg   ri   rn   rr   r   r   r   r   r   r   r   r   r   r   r   r   <module>r     s     !   w /	%8;^ 8;v~ 
=* =@+<n +<\7 	< 	<!' !'H !;G !;Hh' h'V	**~ **Z(J> (JV'>. >B5? 5?r   