Class: CZMQ::FFI::Zcertstore
- Inherits:
-
Object
- Object
- CZMQ::FFI::Zcertstore
- Defined in:
- lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb
Overview
This class is 100% generated using zproject.
work with CURVE security certificate stores
Defined Under Namespace
Classes: DestroyedError
Class Method Summary collapse
- .__new ⇒ Object
- .create_finalizer_for(ptr) ⇒ Proc
-
.destructor ⇒ Object
Create a new callback of the following type: Destructor for loader state.
-
.loader ⇒ Object
Create a new callback of the following type: Loaders retrieve certificates from an arbitrary source.
-
.new(location) ⇒ CZMQ::Zcertstore
Create a new certificate store from a disk directory, loading and indexing all certificates in that location.
-
.test(verbose) ⇒ void
Self test of this class.
Instance Method Summary collapse
-
#__ptr ⇒ ::FFI::Pointer
(also: #to_ptr)
Return internal pointer.
-
#__ptr_give_ref ⇒ ::FFI::MemoryPointer
Nullify internal pointer and return pointer pointer.
-
#__undef_finalizer ⇒ void
Undefines the finalizer for this object.
-
#certs ⇒ Zlistx
Return a list of all the certificates in the store.
-
#destroy ⇒ void
Destroy a certificate store object in memory.
-
#empty ⇒ void
Empty certificate hashtable.
-
#initialize(ptr, finalize = true) ⇒ Zcertstore
constructor
Attaches the pointer ptr to this instance and defines a finalizer for it if necessary.
-
#insert(cert_p) ⇒ void
Insert certificate into certificate store in memory.
-
#lookup(public_key) ⇒ Zcert
Look up certificate by public key, returns zcert_t object if found, else returns NULL.
- #null? ⇒ Boolean
-
#print ⇒ void
Print list of certificates in store to logging facility.
-
#set_loader(loader, destructor, state) ⇒ void
Override the default disk loader with a custom loader fn.
Constructor Details
#initialize(ptr, finalize = true) ⇒ Zcertstore
Attaches the pointer ptr to this instance and defines a finalizer for it if necessary.
24 25 26 27 28 29 30 31 32 |
# 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 |
Class Method Details
.__new ⇒ Object
18 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb', line 18 alias :__new :new |
.create_finalizer_for(ptr) ⇒ Proc
35 36 37 38 39 40 41 |
# 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 ⇒ Object
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.
Create a new callback of the following type: Destructor for loader state.
typedef void (zcertstore_destructor) (
void **self_p);
102 103 104 105 106 107 |
# 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 ⇒ Object
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.
Create a new callback of the following type: Loaders retrieve certificates from an arbitrary source.
typedef void (zcertstore_loader) (
zcertstore_t *self);
85 86 87 88 89 90 91 |
# 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(location) ⇒ CZMQ::Zcertstore
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.
117 118 119 120 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb', line 117 def self.new(location) ptr = ::CZMQ::FFI.zcertstore_new(location) __new ptr end |
.test(verbose) ⇒ void
This method returns an undefined value.
Self test of this class
212 213 214 215 216 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb', line 212 def self.test(verbose) verbose = !(0==verbose||!verbose) # boolean result = ::CZMQ::FFI.zcertstore_test(verbose) result end |
Instance Method Details
#__ptr ⇒ ::FFI::Pointer Also known as: to_ptr
Return internal pointer
48 49 50 51 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb', line 48 def __ptr raise DestroyedError unless @ptr @ptr end |
#__ptr_give_ref ⇒ ::FFI::MemoryPointer
This detaches the current instance from the native object and thus makes it unusable.
Nullify internal pointer and return pointer pointer.
59 60 61 62 63 64 65 66 |
# 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 ⇒ void
Only use this if you need to and can guarantee that the native object will be freed by other means.
This method returns an undefined value.
Undefines the finalizer for this object.
71 72 73 74 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb', line 71 def __undef_finalizer ObjectSpace.undefine_finalizer self @finalizer = nil end |
#certs ⇒ Zlistx
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.
200 201 202 203 204 205 206 |
# 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 ⇒ void
This method returns an undefined value.
Destroy a certificate store object in memory. Does not affect anything stored on disk.
126 127 128 129 130 131 |
# 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 ⇒ void
This method returns an undefined value.
Empty certificate hashtable. This wrapper exists to be friendly to bindings, which don’t usually have access to struct internals.
177 178 179 180 181 182 |
# 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) ⇒ void
This method returns an undefined value.
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.
165 166 167 168 169 170 171 |
# 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) ⇒ Zcert
Look up certificate by public key, returns zcert_t object if found, else returns NULL. The public key is provided in Z85 text format.
151 152 153 154 155 156 157 |
# 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? ⇒ Boolean
43 44 45 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb', line 43 def null? !@ptr or @ptr.null? end |
#print ⇒ void
This method returns an undefined value.
Print list of certificates in store to logging facility
187 188 189 190 191 192 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb', line 187 def print() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zcertstore_print(self_p) result end |
#set_loader(loader, destructor, state) ⇒ void
This method returns an undefined value.
Override the default disk loader with a custom loader fn.
139 140 141 142 143 144 |
# 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 |