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

Method next

bindings/rust/src/cmap.rs:830–886  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

828 type Item = CmapIter;
829
830 fn next(&mut self) -> Option<CmapIter> {
831 let mut c_key_name = [0u8; CMAP_KEYNAME_MAXLENGTH + 1];
832 let mut c_value_len = 0usize;
833 let mut c_value_type = 0u32;
834 let res = unsafe {
835 ffi::cmap_iter_next(
836 self.cmap_handle,
837 self.iter_handle,
838 c_key_name.as_mut_ptr() as *mut c_char,
839 &mut c_value_len,
840 &mut c_value_type,
841 )
842 };
843 if res == ffi::CS_OK {
844 // Return the Data for this iteration
845 let mut c_value = vec![0u8; c_value_len];
846 let res = unsafe {
847 ffi::cmap_get(
848 self.cmap_handle,
849 c_key_name.as_ptr() as *mut c_char,
850 c_value.as_mut_ptr() as *mut c_void,
851 &mut c_value_len,
852 &mut c_value_type,
853 )
854 };
855 if res == ffi::CS_OK {
856 match c_to_data(c_value_len, c_value_type, c_value.as_ptr()) {
857 Ok(d) => {
858 let r_keyname = match string_from_bytes(
859 c_key_name.as_ptr() as *mut c_char,
860 CMAP_KEYNAME_MAXLENGTH,
861 ) {
862 Ok(s) => s,
863 Err(_) => return None,
864 };
865 Some(CmapIter {
866 key_name: r_keyname,
867 data: d,
868 })
869 }
870 Err(_) => None,
871 }
872 } else {
873 // cmap_get returned error
874 None
875 }
876 } else if res == ffi::CS_ERR_NO_SECTIONS {
877 // End of list
878 unsafe {
879 // Yeah, we don't check this return code. There's nowhere to report it.
880 ffi::cmap_iter_finalize(self.cmap_handle, self.iter_handle)
881 };
882 None
883 } else {
884 None
885 }
886 }
887}

Callers

nothing calls this directly

Calls 5

cmap_iter_nextFunction · 0.85
cmap_getFunction · 0.85
c_to_dataFunction · 0.85
string_from_bytesFunction · 0.85
cmap_iter_finalizeFunction · 0.85

Tested by

no test coverage detected