pub trait TypedExternal: 'static {
const TYPE_NAME: &'static str;
const TYPE_NAME_CSTR: &'static [u8];
const TYPE_ID_CSTR: &'static [u8];
}Expand description
Trait for types that can be stored in an ExternalPtr.
This provides the type identification needed for runtime type checking.
Type identification uses R’s symbol interning (Rf_install) for fast
pointer-based comparison.
§Type ID vs Type Name
-
TYPE_ID_CSTR: Namespaced identifier used for type checking (stored inprot[0]). Format:"<crate_name>@<crate_version>::<module_path>::<type_name>\0"The crate name and version ensure:
- Same type from same crate+version → compatible (can share ExternalPtr)
- Same type name from different crates → incompatible
- Same type from different crate versions → incompatible
-
TYPE_NAME_CSTR: Short display name for the R tag (shown when printing). Just the type identifier for readability.
Required Associated Constants§
Sourceconst TYPE_NAME_CSTR: &'static [u8]
const TYPE_NAME_CSTR: &'static [u8]
The type name as a null-terminated C string (for R tag display)
Sourceconst TYPE_ID_CSTR: &'static [u8]
const TYPE_ID_CSTR: &'static [u8]
Namespaced type ID as a null-terminated C string (for type checking).
This should include the module path to prevent cross-package collisions.
Use concat!(module_path!(), "::", stringify!(Type), "\0").as_bytes()
when implementing manually, or use #[derive(ExternalPtr)].
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.