MCPcopy Create free account
hub / github.com/apache/fory / gen_struct_version_hash_ts

Function gen_struct_version_hash_ts

rust/fory-derive/src/object/util.rs:829–848  ·  view source on GitHub ↗

Generates TokenStream for struct version hash (computed at compile time).

(fields: &[&Field])

Source from the content-addressed store, hash-verified

827
828/// Generates TokenStream for struct version hash (computed at compile time).
829pub(crate) fn gen_struct_version_hash_ts(fields: &[&Field]) -> TokenStream {
830 let fingerprint = compute_struct_fingerprint(fields);
831 let (hash, _) = fory_core::util::murmurhash3_x64_128(fingerprint.as_bytes(), 47);
832 let version_hash = (hash & 0xFFFF_FFFF) as i32;
833
834 quote! {
835 {
836 const VERSION_HASH: i32 = #version_hash;
837 if fory_core::util::ENABLE_FORY_DEBUG_OUTPUT {
838 println!(
839 "[rust][fory-debug] struct {} version fingerprint=\"{}\" hash={}",
840 ::std::any::type_name::<Self>(),
841 #fingerprint,
842 VERSION_HASH
843 );
844 }
845 VERSION_HASH
846 }
847 }
848}
849
850pub(crate) fn is_skip_field(field: &syn::Field) -> bool {
851 super::field_meta::is_skip_field(field)

Callers 2

gen_read_dataFunction · 0.85
gen_write_dataFunction · 0.85

Calls 2

murmurhash3_x64_128Function · 0.85

Tested by

no test coverage detected