class_docstr: An output target you can connect action signals to to implement
  behaviour.
class_docstr_tok: ["An","output","target","you","can","connect","action","signals","to","to","implement","behaviour","."]
docstr: 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.
  
  Read handlers are optional for targets. If you do not set one, your
  target will be treated as unreadable and libvips will be unable to
  write some file types (just TIFF, as of the time of writing).
docstr_tok: ["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",".","Read","handlers","are","optional","for","targets",".","If","you","do","not","set","one",",","your","target","will","be","treated","as","unreadable","and","libvips","will","be","unable","to","write","some","file","types","(","just","TIFF",",","as","of","the","time","of","writing",")","."]
code: def on_read(self, handler):
      """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.
  
      Read handlers are optional for targets. If you do not set one, your
      target will be treated as unreadable and libvips will be unable to
      write some file types (just TIFF, as of the time of writing).
  
      """
  
      def interface_handler(buf):
          chunk = handler(len(buf))
          if chunk is None:
              return 0
  
          bytes_read = len(chunk)
          buf[:bytes_read] = chunk
  
          return bytes_read
  
      if at_least_libvips(8, 13):
          self.signal_connect("read", interface_handler)
  
file_path: pyvips/pyvips/vtargetcustom.py
imports: from __future__ import division
  import logging
  import pyvips
  from pyvips import ffi, vips_lib, at_least_libvips
label_desc: Use image node_id 3 for calling the TargetCustom obj's underlying member method code with example usage: obj.on_read(handler) and returns: bytes_read, int