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.
-
#state ⇒ ::FFI::Pointer
Return the state stored in certstore.
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 42 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb', line 35 def self.create_finalizer_for(ptr) ptr_ptr = ::FFI::MemoryPointer.new :pointer Proc.new do 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);
103 104 105 106 107 108 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb', line 103 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);
86 87 88 89 90 91 92 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb', line 86 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.
118 119 120 121 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb', line 118 def self.new(location) ptr = ::CZMQ::FFI.zcertstore_new(location) __new ptr end |
Instance Method Details
#__ptr ⇒ ::FFI::Pointer Also known as: to_ptr
Return internal pointer
49 50 51 52 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb', line 49 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.
60 61 62 63 64 65 66 67 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb', line 60 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.
72 73 74 75 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb', line 72 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.
201 202 203 204 205 206 207 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb', line 201 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.
127 128 129 130 131 132 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb', line 127 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.
178 179 180 181 182 183 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb', line 178 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.
166 167 168 169 170 171 172 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb', line 166 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.
152 153 154 155 156 157 158 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb', line 152 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
44 45 46 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb', line 44 def null? !@ptr or @ptr.null? end |
#print ⇒ void
This method returns an undefined value.
Print list of certificates in store to logging facility
188 189 190 191 192 193 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb', line 188 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.
140 141 142 143 144 145 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb', line 140 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 ⇒ ::FFI::Pointer
Return the state stored in certstore
212 213 214 215 216 217 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb', line 212 def state() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zcertstore_state(self_p) result end |