Skip to main content

embed_package_metadata

Function embed_package_metadata 

Source
pub fn embed_package_metadata(
    md: &PackageMetadata,
    opts: &EmbedOptions,
) -> ModuleInfoResult<EmbedArtifacts>
Expand description

Embed a PackageMetadata value into ELF note artifacts on disk.

Consumers that want to supply metadata programmatically (e.g. from build.rs without editing Cargo.toml) or suppress the cargo:rustc-link-arg directive (e.g. a static library whose final link happens in a later build step) call this directly; the zero-config generate_project_metadata_and_linker_script is a thin wrapper over this function with the default options.

ยงErrors

Returns ModuleInfoError::MetadataTooLarge if the serialized JSON exceeds the 1 KiB .note.package payload limit, or ModuleInfoError::MalformedJson if a required field is missing. IoError on filesystem failures.