Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aien-sovereign-core-mv/blob/main/crates/rad-id-sync/src/ffi.rs # aien-sovereign-core-mv AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aien-sovereign-core-mv / crates / rad-id-sync / src / ffi.rs` 59 lines ยท 1913 bytes Raw Blame History 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2026 Drake Stapleton (AIEN / aien-dev) 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 16 use crate::identity::IdentityAnchor; 17 use crate::keys::sync_identity_keys; 18 use std::ffi::CString; 19 use std::os::raw::c_char; 20 21 #[no_mangle] 22 pub extern "C" fn rad_id_sync_status_json() -> *mut c_char { 23 let result = match IdentityAnchor::load_or_init() { 24 Ok(anchor) => match sync_identity_keys(anchor) { 25 Ok((_, report)) => serde_json::to_string(&report) 26 .unwrap_or_else(|e| format!("{{\"error\":\"{}\"}}", e)), 27 Err(e) => format!("{{\"error\":\"{}\"}}", e), 28 }, 29 Err(e) => format!("{{\"error\":\"{}\"}}", e), 30 }; 31 32 CString::new(result).unwrap_or_default().into_raw() 33 } 34 35 #[no_mangle] 36 /// # Safety 37 /// 38 /// The `ptr` pointer must be a valid pointer allocated by `rad_id_sync_status_json` or null. 39 pub unsafe extern "C" fn rad_id_sync_free_string(ptr: *mut c_char) { 40 if !ptr.is_null() { 41 unsafe { 42 let _ = CString::from_raw(ptr); 43 } 44 } 45 } 46 47 #[no_mangle] 48 pub extern "C" fn rad_id_sync_is_valid() -> i32 { 49 match IdentityAnchor::load_or_init() { 50 Ok(anchor) => { 51 if anchor.primary_radicle_key.is_some() || anchor.primary_ssh_key.is_some() { 52 1 53 } else { 54 0 55 } 56 } 57 Err(_) => 0, 58 } 59 }