MCPcopy Create free account
hub / github.com/corosync/corosync / initialize

Function initialize

bindings/rust/src/cfg.rs:129–150  ·  view source on GitHub ↗

Initialize a connection to the cfg library. You must call this before doing anything else and use the passed back [Handle]. Remember to free the handle using [finalize] when finished.

(callbacks: &Callbacks)

Source from the content-addressed store, hash-verified

127/// else and use the passed back [Handle].
128/// Remember to free the handle using [finalize] when finished.
129pub fn initialize(callbacks: &Callbacks) -> Result<Handle> {
130 let mut handle: ffi::corosync_cfg_handle_t = 0;
131
132 let c_callbacks = ffi::corosync_cfg_callbacks_t {
133 corosync_cfg_shutdown_callback: Some(rust_shutdown_notification_fn),
134 };
135
136 unsafe {
137 let res = ffi::corosync_cfg_initialize(&mut handle, &c_callbacks);
138 if res == ffi::CS_OK {
139 let rhandle = Handle {
140 cfg_handle: handle,
141 callbacks: *callbacks,
142 clone: false,
143 };
144 HANDLE_HASH.lock().unwrap().insert(handle, rhandle.clone());
145 Ok(rhandle)
146 } else {
147 Err(CsError::from_c(res))
148 }
149 }
150}
151
152/// Finish with a connection to corosync, after calling this the [Handle] is invalid
153pub fn finalize(handle: &Handle) -> Result<()> {

Callers

nothing calls this directly

Calls 2

corosync_cfg_initializeFunction · 0.85
cloneMethod · 0.45

Tested by

no test coverage detected