module Libvirt::FFI::Storage

Constants

EVENT_ID_TO_CALLBACK

Public Instance Methods

event_callback_for(event_id, &block) click to toggle source

Creates event callback function for provided event_id @param event_id [Integer,Symbol] @yield connect_ptr, pool_ptr, *args, opaque_ptr @return [FFI::Function]

# File lib/libvirt/ffi/storage.rb, line 223
def event_callback_for(event_id, &block)
  event_id_sym = event_id.is_a?(Symbol) ? event_id : enum_type(:event_id)[event_id]

  callback_name = EVENT_ID_TO_CALLBACK.fetch(event_id_sym)
  callback_function(callback_name) do |*args|
    Util.log(:debug, name) { ".event_callback_for #{event_id_sym} CALLBACK #{args.map(&:to_s).join(', ')}," }
    block.call(*args)
  end
end