
    Dh>                     x    d dl Z d dlZd dlmZmZ  e j                  e      Z G d dej                        ZdgZ	y)    N)ffivips_libc                   .     e Zd ZdZ fdZd Zd Z xZS )SourceCustomzCustom sources allow reading data from otherwise unsupported sources.
    Requires libvips `>= 8.9.0`.

    To use, create a SourceCustom object, then provide callbacks to
    :meth:`on_read` and :meth:`on_seek`.
    c                 |    t        j                  dt        j                               }t        t
        |   |       y)zoMake a new custom source.

        You can pass this source to (for example) :meth:`new_from_source`.

        zVipsSource*N)r   castr   vips_source_custom_newsuperr   __init__)selfsource	__class__s     v/var/www/fastuser/data/www/generator.snapmosaic.io/flask_app/venv/lib/python3.12/site-packages/pyvips/vsourcecustom.pyr   zSourceCustom.__init__   s-     -)H)H)JKlD*62    c                 4    fd}| j                  d|       y)a!  Attach a read handler.

        The interface is exactly as io.read(). The handler is given a number
        of bytes to fetch, and should return a bytes-like object containing up
        to that number of bytes. If there is no more data available, it should
        return None.

        c                 P     t        |             }|yt        |      }|| d | |S )Nr   )len)bufchunk
bytes_readhandlers      r   interface_handlerz/SourceCustom.on_read.<locals>.interface_handler%   s4    CH%E}UJ$Cr   readNsignal_connect)r   r   r   s    ` r   on_readzSourceCustom.on_read   s    	 	F$56r   c                 (    | j                  d|       y)a  Attach a seek handler.

        The interface is the same as io.seek(), so the handler is passed
        parameters for offset and whence with the same meanings.

        However, the handler MUST return the new seek position. A simple way
        to do this is to call io.tell() and return that result.

        Seek handlers are optional. If you do not set one, your source will be
        treated as unseekable and libvips will do extra caching.

        seekNr   )r   r   s     r   on_seekzSourceCustom.on_seek1   s     	FG,r   )__name__
__module____qualname____doc__r   r   r   __classcell__)r   s   @r   r   r   	   s    37,-r   r   )
loggingpyvipsr   r   	getLoggerr    loggerSourcer   __all__ r   r   <module>r,      s;       			8	$6-6== 6-r 
r   