lib.rs (3538B)
1 #![doc = "HarvestCircle `UniFFI` boundary."] 2 #![cfg_attr(coverage_nightly, feature(coverage_attribute))] 3 4 mod commands; 5 mod contract; 6 mod dto; 7 mod host_runtime; 8 mod keyring_worker; 9 mod observer; 10 11 pub use commands::{ 12 BuildInfoDto, GeneratedRecoveryRequest, HarvestCircleAppCore, HarvestCircleError, 13 IdentityCommandReceiptDto, RelayBootstrapInputDto, RemovalRequest, RequestContextDto, 14 RuntimeOpenInputDto, build_info, 15 }; 16 pub use contract::{ 17 DISTRIBUTION_PACKAGE_VERSION, FFI_CONTRACT_HASH, FFI_CONTRACT_ID, FFI_CONTRACT_MAJOR, 18 FFI_CONTRACT_MINOR, MINIMUM_SCHEMA_VERSION, PRODUCT_COORDINATE_DIGEST, PRODUCT_VERSION, 19 SNAPSHOT_SCHEMA_VERSION, SOURCE_FOUNDATION_BASELINE, SOURCE_PROVENANCE_DIGEST, 20 }; 21 pub use dto::{ 22 ActiveIdentityDto, AppLifecycleDto, AppSnapshotDto, IdentityDto, NostrReferenceKindDto, 23 NostrReferenceParseDto, ProfileDto, ProfileLoadStateDto, RelayConnectionStateDto, 24 RelayDestinationDto, RelayEndpointDto, SafeErrorDto, SessionStateDto, SignerAvailabilityDto, 25 SignerBindingKindDto, WireErrorCategory, WireErrorCode, WireRecoveryAction, 26 }; 27 pub use observer::{ 28 HarvestCircleChangeObserver, ObserverSubscription, ShutdownReceiptDto, SnapshotChangeDto, 29 }; 30 31 uniffi::setup_scaffolding!(); 32 33 #[cfg_attr(not(coverage_nightly), uniffi::export)] 34 #[must_use] 35 pub fn native_runtime_version() -> String { 36 PRODUCT_VERSION.to_owned() 37 } 38 39 #[cfg_attr(not(coverage_nightly), uniffi::export)] 40 #[must_use] 41 pub fn generate_operation_id_v7() -> String { 42 harvestcircle_application::DurableRequestId::new_v7() 43 .as_str() 44 .to_owned() 45 } 46 47 #[cfg_attr(not(coverage_nightly), uniffi::export)] 48 #[must_use] 49 pub fn classify_nostr_reference(raw: String) -> NostrReferenceParseDto { 50 harvestcircle_nostr::classify_reference(&raw).into() 51 } 52 53 #[cfg(test)] 54 #[cfg_attr(coverage_nightly, coverage(off))] 55 mod tests { 56 #[test] 57 fn native_runtime_reports_the_product_version_independently() { 58 assert_eq!(super::native_runtime_version(), "0.1.0-alpha"); 59 assert_eq!(super::PRODUCT_VERSION, "0.1.0-alpha"); 60 assert_eq!(env!("CARGO_PKG_VERSION"), "0.1.0-alpha"); 61 assert_eq!(super::FFI_CONTRACT_ID, "harvestcircle-desktop-ffi-v4"); 62 assert_eq!(super::FFI_CONTRACT_MAJOR, 4); 63 assert_eq!(super::FFI_CONTRACT_MINOR, 5); 64 assert_eq!(super::SNAPSHOT_SCHEMA_VERSION, 1); 65 assert_eq!( 66 super::PRODUCT_COORDINATE_DIGEST, 67 harvestcircle_product::PRODUCT_COORDINATE_DIGEST 68 ); 69 assert_eq!(super::DISTRIBUTION_PACKAGE_VERSION, "1.0.0"); 70 assert_eq!(super::FFI_CONTRACT_HASH.len(), 64); 71 assert!(!super::contract::NORMALIZED_CONTRACT_METADATA.is_empty()); 72 let operation_id = super::generate_operation_id_v7(); 73 assert!(harvestcircle_application::DurableRequestId::parse(operation_id).is_ok()); 74 let build = super::build_info(); 75 assert_eq!(build.ffi_contract_id, super::FFI_CONTRACT_ID); 76 assert_eq!(build.ffi_contract_hash, super::FFI_CONTRACT_HASH); 77 assert_eq!(build.provenance_digest.len(), 64); 78 assert_eq!( 79 build.current_storage_schema_version, 80 harvestcircle_storage::CURRENT_SCHEMA_VERSION 81 ); 82 for value in [ 83 build.source_commit, 84 build.radroots_revision, 85 build.rust_toolchain, 86 build.java_toolchain, 87 build.kotlin_toolchain, 88 ] { 89 assert!(!value.is_empty()); 90 assert!(!value.contains(['\n', '\r'])); 91 } 92 } 93 }