/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Functions to calculate names for FFI symbols //! //! All of these functions input a `namespace` parameter which is: //! - The UDL namespace for UDL-based generation //! - The "module path" of the item for proc-macro based generation. Right now this is actually just the //! crate name, but we eventually hope to make this the full module path. //! //! This could cause collisions in the case where you combine UDL and proc-macro generation and you //! set the UDL namespace to the name of another crate. This seems so pathological that it's not //! worth the code complexity to prevent it.
usecrate::crate_name;
/// FFI symbol name for a top-level function pubfn fn_symbol_name(module_path: &str, name: &str) -> String { let namespace = crate_name(module_path).replace("::", "__"); let name = name.to_ascii_lowercase();
format!("uniffi_{namespace}_fn_func_{name}")
}
/// FFI symbol name for an object constructor pubfn constructor_symbol_name(module_path: &str, object_name: &str, name: &str) -> String { let namespace = crate_name(module_path).replace("::", "__"); let object_name = object_name.to_ascii_lowercase(); let name = name.to_ascii_lowercase();
format!("uniffi_{namespace}_fn_constructor_{object_name}_{name}")
}
/// FFI symbol name for an object method pubfn method_symbol_name(module_path: &str, object_name: &str, name: &str) -> String { let namespace = crate_name(module_path).replace("::", "__"); let object_name = object_name.to_ascii_lowercase(); let name = name.to_ascii_lowercase();
format!("uniffi_{namespace}_fn_method_{object_name}_{name}")
}
/// FFI symbol name for the `clone` function for an object. pubfn clone_fn_symbol_name(module_path: &str, object_name: &str) -> String { let namespace = crate_name(module_path).replace("::", "__"); let object_name = object_name.to_ascii_lowercase();
format!("uniffi_{namespace}_fn_clone_{object_name}")
}
/// FFI symbol name for the `free` function for an object. pubfn free_fn_symbol_name(module_path: &str, object_name: &str) -> String { let namespace = crate_name(module_path).replace("::", "__"); let object_name = object_name.to_ascii_lowercase();
format!("uniffi_{namespace}_fn_free_{object_name}")
}
/// FFI symbol name for the `init_callback` function for a callback interface pubfn init_callback_vtable_fn_symbol_name(
module_path: &str,
callback_interface_name: &str,
) -> String { let namespace = crate_name(module_path).replace("::", "__"); let callback_interface_name = callback_interface_name.to_ascii_lowercase();
format!("uniffi_{namespace}_fn_init_callback_vtable_{callback_interface_name}")
}
/// FFI checksum symbol name for a top-level function pubfn fn_checksum_symbol_name(module_path: &str, name: &str) -> String { let namespace = crate_name(module_path).replace("::", "__"); let name = name.to_ascii_lowercase();
format!("uniffi_{namespace}_checksum_func_{name}")
}
/// FFI checksum symbol name for an object constructor pubfn constructor_checksum_symbol_name(
module_path: &str,
object_name: &str,
name: &str,
) -> String { let namespace = crate_name(module_path).replace("::", "__"); let object_name = object_name.to_ascii_lowercase(); let name = name.to_ascii_lowercase();
format!("uniffi_{namespace}_checksum_constructor_{object_name}_{name}")
}
/// FFI checksum symbol name for an object method pubfn method_checksum_symbol_name(module_path: &str, object_name: &str, name: &str) -> String { let namespace = crate_name(module_path).replace("::", "__"); let object_name = object_name.to_ascii_lowercase(); let name = name.to_ascii_lowercase();
format!("uniffi_{namespace}_checksum_method_{object_name}_{name}")
}
/// Get the symbol name for a FFI-buffer version of a function pubfn ffi_buffer_symbol_name(fn_name: &str) -> String { match fn_name.strip_prefix("uniffi_") {
Some(rest) => format!("uniffi_ffibuffer_{rest}"), // this should never happen, but if it does let's try our best to prefix things properl.
None => format!("uniffi_ffibuffer_{fn_name}"),
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet am 2026-08-27)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.