You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: filter.rb
    path of file: ./repos/hexapdf/lib/hexapdf
    
    the code of the file until where you have to start completion: # -*- encoding: utf-8; frozen_string_literal: true -*-
#
#--
# This file is part of HexaPDF.
#
# HexaPDF - A Versatile PDF Creation and Manipulation Library For Ruby
# Copyright (C) 2014-2024 Thomas Leitner
#
# HexaPDF is free software: you can redistribute it a
    
    def self.source_from_io(io, pos: 0, length: -1, chunk_size: 0)
      orig_length = length
      chunk_size = 2**20 if chunk_size <= 0
      chunk_size = length if length >= 0 && chunk_size > length
      length = 2**61 if length < 0
      pos = 0 if pos < 0

      FiberWithLength.new(orig_length) do
        while length > 0 && (io.pos = pos) && (data = io.read(chunk_size))
          pos = io.pos
          length -= data.size
          chunk_size = length if chunk_size > length
          Fiber.yield(data)
        end
        if length > 0 && orig_length >= 0
          raise FilterError, "Couldn't read all requested bytes before encountering EOF"
        end