Skip to main content

Abi

Trait Abi 

Source
pub trait Abi {
    // Required methods
    fn target_os(&self) -> TargetOperatingSystem;
    fn mangle_function_name(&self, name: &str) -> String;

    // Provided method
    fn call_stub(&self, name: &str) -> Option<String> { ... }
}
Expand description

Trait defining the common interface for all ABI implementations.

This trait provides a standardized way to interact with platform-specific ABI details across different architectures. Each backend implements this trait to provide architecture and OS-specific behavior.

Required Methods§

Source

fn target_os(&self) -> TargetOperatingSystem

Returns the target operating system for this ABI instance.

Source

fn mangle_function_name(&self, name: &str) -> String

Returns the mangled function name with platform-specific prefix.

This method handles platform-specific symbol naming conventions, such as the underscore prefix on macOS.

Provided Methods§

Source

fn call_stub(&self, name: &str) -> Option<String>

Maps well-known intrinsic/runtime names to platform symbol stubs.

Returns None if the name is not a known intrinsic that needs special handling. This allows backends to map internal names (like “print”) to platform-specific symbols (like “_printf” on macOS).

Default implementation returns None for all names, meaning no special mapping is needed.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§