Class: LibStorj::Ext::Storj::GetBucketRequest

Inherits:
FFI::Struct
  • Object
show all
Defined in:
lib/ruby-libstorj/ext/get_bucket_request.rb

Class Method Summary collapse

Class Method Details

.after_work_cbObject



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/ruby-libstorj/ext/get_bucket_request.rb', line 19

def self.after_work_cb
  args = [::LibStorj::Ext::UV::Work.by_ref, :int]

  FFI::Function.new :void, args do |work_req_ptr|
    req = self.new work_req_ptr[:data]
    buckets,total_buckets = req.values_at %i[buckets total_buckets]
    error = ::LibStorj::Ext::Curl.curl_code_to_string req[:error_code]
    c_handle = FFI::Function.new :void, %i[string pointer int], req[:handle]

    c_handle.call error, buckets, total_buckets
  end
end

.ruby_handleObject



32
33
34
35
36
37
38
39
40
41
# File 'lib/ruby-libstorj/ext/get_bucket_request.rb', line 32

def self.ruby_handle
  FFI::Function.new :void, %i[string pointer int] do
  |error, buckets_pointer, bucket_count|
    buckets = ::LibStorj::Ext::Storj::Bucket
                  .pointer_to_array buckets_pointer,
                                    bucket_count

    yield error, buckets
  end
end