Module: Libvirt::FFI::Network

Extended by:
FFI::Library, Helpers
Defined in:
lib/libvirt/ffi/network.rb

Defined Under Namespace

Classes: DhcpLeaseStruct

Constant Summary collapse

EVENT_ID_TO_CALLBACK =
{
    LIFECYCLE: :virConnectNetworkEventLifecycleCallback
}.freeze

Class Method Summary collapse

Methods included from Helpers

callback_function

Class Method Details

.event_callback_for(event_id) { ... } ⇒ FFI::Function

Creates event callback function for provided event_id

Parameters:

  • event_id (Integer, Symbol)

Yields:

  • connect_ptr, network_ptr, *args, opaque_ptr

Returns:

  • (FFI::Function)


381
382
383
384
385
386
387
388
389
# File 'lib/libvirt/ffi/network.rb', line 381

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