Skip to main content

EmbedOptions

Struct EmbedOptions 

Source
#[non_exhaustive]
pub struct EmbedOptions { pub out_dir: Option<PathBuf>, pub emit_cargo_link_arg: bool, }
Expand description

Options controlling how embed_package_metadata writes artifacts and whether it emits cargo link-arg directives.

EmbedOptions::default() preserves the original zero-config behavior: write to $OUT_DIR and emit cargo:rustc-link-arg=-T<linker_script.ld>. Override when the crate is a static library whose final link happens later in the outer build system.

§Non-exhaustive

This struct is #[non_exhaustive] so new options can land without a SemVer break. Use ..Default::default() when constructing.

§Example

// Static-library flow: write the linker script to a directory the outer
// build system knows about, so it can pass the script to the final linker.
// In practice `out_dir` comes from an env var the outer build sets, or a
// subdirectory of `OUT_DIR`; here we use `env::temp_dir()` as a portable
// placeholder. `EmbedOptions` is `#[non_exhaustive]`, so construct via
// `Default` and assign fields rather than using struct-literal syntax.
let mut opts = EmbedOptions::default();
opts.out_dir = Some(std::env::temp_dir().join("module_info_linker"));
opts.emit_cargo_link_arg = false;

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§out_dir: Option<PathBuf>

Directory where linker_script.ld, note.package.bin, and module_info.json are written. When None, the OUT_DIR environment variable is used (the normal cargo build-script case).

§emit_cargo_link_arg: bool

When true, emit cargo:rustc-link-arg=-T<path-to-linker_script.ld> on stdout so cargo passes the script to the final link step.

Set to false when the current crate is a static library whose final link happens later in the outer build system. Have that system pass the linker script to its own linker.

Trait Implementations§

Source§

impl Clone for EmbedOptions

Source§

fn clone(&self) -> EmbedOptions

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EmbedOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for EmbedOptions

Available on Linux only.
Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.