class CZMQ::FFI::Zcertstore

work with CURVE security certificate stores @note This class is 100% generated using zproject.

Public Class Methods

__new(location)
Alias for: new
create_finalizer_for(ptr) click to toggle source

@param ptr [::FFI::Pointer] @return [Proc]

# File lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb, line 35
def self.create_finalizer_for(ptr)
  Proc.new do
    ptr_ptr = ::FFI::MemoryPointer.new :pointer
    ptr_ptr.write_pointer ptr
    ::CZMQ::FFI.zcertstore_destroy ptr_ptr
  end
end
destructor() { |self_p| ... } click to toggle source

Create a new callback of the following type: Destructor for loader state.

typedef void (zcertstore_destructor) (
    void **self_p);

@note WARNING: If your Ruby code doesn't retain a reference to the

FFI::Function object after passing it to a C function call,
it may be garbage collected while C still holds the pointer,
potentially resulting in a segmentation fault.
# File lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb, line 102
def self.destructor
  ::FFI::Function.new :void, [:pointer], blocking: true do |self_p|
    result = yield self_p
    result
  end
end
loader() { |self_| ... } click to toggle source

Create a new callback of the following type: Loaders retrieve certificates from an arbitrary source.

typedef void (zcertstore_loader) (
    zcertstore_t *self);

@note WARNING: If your Ruby code doesn't retain a reference to the

FFI::Function object after passing it to a C function call,
it may be garbage collected while C still holds the pointer,
potentially resulting in a segmentation fault.
# File lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb, line 85
def self.loader
  ::FFI::Function.new :void, [:pointer], blocking: true do |self_|
    self_ = Zcertstore.__new self_, false
    result = yield self_
    result
  end
end
new(ptr, finalize = true) click to toggle source

Attaches the pointer ptr to this instance and defines a finalizer for it if necessary. @param ptr [::FFI::Pointer] @param finalize [Boolean]

# File lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb, line 24
def initialize(ptr, finalize = true)
  @ptr = ptr
  if @ptr.null?
    @ptr = nil # Remove null pointers so we don't have to test for them.
  elsif finalize
    @finalizer = self.class.create_finalizer_for @ptr
    ObjectSpace.define_finalizer self, @finalizer
  end
end
new(location) click to toggle source

Create a new certificate store from a disk directory, loading and indexing all certificates in that location. The directory itself may be absent, and created later, or modified at any time. The certificate store is automatically refreshed on any zcertstore_lookup() call. If the location is specified as NULL, creates a pure-memory store, which you can work with by inserting certificates at runtime. @param location [String, to_s, nil] @return [CZMQ::Zcertstore]

# File lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb, line 117
def self.new(location)
  ptr = ::CZMQ::FFI.zcertstore_new(location)
  __new ptr
end
Also aliased as: __new
test(verbose) click to toggle source

Self test of this class

@param verbose [Boolean] @return [void]

# File lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb, line 222
def self.test(verbose)
  verbose = !(0==verbose||!verbose) # boolean
  result = ::CZMQ::FFI.zcertstore_test(verbose)
  result
end

Public Instance Methods

__ptr() click to toggle source

Return internal pointer @return [::FFI::Pointer]

# File lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb, line 48
def __ptr
  raise DestroyedError unless @ptr
  @ptr
end
Also aliased as: to_ptr
__ptr_give_ref() click to toggle source

Nullify internal pointer and return pointer pointer. @note This detaches the current instance from the native object

and thus makes it unusable.

@return [::FFI::MemoryPointer] the pointer pointing to a pointer

pointing to the native object
# File lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb, line 59
def __ptr_give_ref
  raise DestroyedError unless @ptr
  ptr_ptr = ::FFI::MemoryPointer.new :pointer
  ptr_ptr.write_pointer @ptr
  __undef_finalizer if @finalizer
  @ptr = nil
  ptr_ptr
end
__undef_finalizer() click to toggle source

Undefines the finalizer for this object. @note Only use this if you need to and can guarantee that the native

object will be freed by other means.

@return [void]

# File lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb, line 71
def __undef_finalizer
  ObjectSpace.undefine_finalizer self
  @finalizer = nil
end
certs() click to toggle source

Return a list of all the certificates in the store. The caller takes ownership of the zlistx_t object and is responsible for destroying it. The caller does not take ownership of the zcert_t objects.

@return [Zlistx]

# File lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb, line 200
def certs()
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zcertstore_certs(self_p)
  result = Zlistx.__new result, true
  result
end
destroy() click to toggle source

Destroy a certificate store object in memory. Does not affect anything stored on disk.

@return [void]

# File lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb, line 126
def destroy()
  return unless @ptr
  self_p = __ptr_give_ref
  result = ::CZMQ::FFI.zcertstore_destroy(self_p)
  result
end
empty() click to toggle source

Empty certificate hashtable. This wrapper exists to be friendly to bindings, which don't usually have access to struct internals.

@return [void]

# File lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb, line 177
def empty()
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zcertstore_empty(self_p)
  result
end
insert(cert_p) click to toggle source

Insert certificate into certificate store in memory. Note that this does not save the certificate to disk. To do that, use zcert_save() directly on the certificate. Takes ownership of zcert_t object.

@param cert_p [#__ptr_give_ref] @return [void]

# File lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb, line 165
def insert(cert_p)
  raise DestroyedError unless @ptr
  self_p = @ptr
  cert_p = cert_p.__ptr_give_ref
  result = ::CZMQ::FFI.zcertstore_insert(self_p, cert_p)
  result
end
lookup(public_key) click to toggle source

Look up certificate by public key, returns zcert_t object if found, else returns NULL. The public key is provided in Z85 text format.

@param public_key [String, to_s, nil] @return [Zcert]

# File lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb, line 151
def lookup(public_key)
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zcertstore_lookup(self_p, public_key)
  result = Zcert.__new result, false
  result
end
null?() click to toggle source

@return [Boolean]

# File lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb, line 43
def null?
  !@ptr or @ptr.null?
end
print() click to toggle source

Print list of certificates in store to logging facility

@return [void]

set_loader(loader, destructor, state) click to toggle source

Override the default disk loader with a custom loader fn.

@param loader [::FFI::Pointer, to_ptr] @param destructor [::FFI::Pointer, to_ptr] @param state [::FFI::Pointer, to_ptr] @return [void]

# File lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb, line 139
def set_loader(loader, destructor, state)
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zcertstore_set_loader(self_p, loader, destructor, state)
  result
end
state() click to toggle source

Return the state stored in certstore

@return [::FFI::Pointer]

# File lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb, line 211
def state()
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zcertstore_state(self_p)
  result
end
to_ptr()

So external Libraries can just pass the Object to a FFI function which expects a :pointer

Alias for: __ptr