FileLocationStrategy

Enum FileLocationStrategy 

Source
pub enum FileLocationStrategy {
    Custom(PathBuf),
    FromAutocxxRsFile(PathBuf),
    FromAutocxxRs(PathBuf),
    FromOutDir(PathBuf),
    FromAutocxxRsJsonArchive(PathBuf),
    UnknownMaybeFromOutdir,
}
Expand description

The strategy used to generate, and to find generated, files. As standard, these are based off the OUT_DIR set by Cargo, but our code can’t assume it can read OUT_DIR as it may be running in the rust-analyzer proc macro server where it’s not available. We need to give provision for custom locations and we need our code generator build script to be able to pass locations through to the proc macro by env vars.

On the whole this class concerns itself with directory names and allows the actual file name to be determined elsewhere (based on a hash of the contents of include_cpp!.) But some types of build system need to know the precise file name produced by the codegen phase and passed into the macro phase, so we have some options for that. See gen --help for details.

Variants§

§

Custom(PathBuf)

§

FromAutocxxRsFile(PathBuf)

§

FromAutocxxRs(PathBuf)

§

FromOutDir(PathBuf)

§

FromAutocxxRsJsonArchive(PathBuf)

§

UnknownMaybeFromOutdir

Implementations§

Source§

impl FileLocationStrategy

Source

pub fn new() -> Self

Source

pub fn new_custom(gen_dir: PathBuf) -> Self

Source

pub fn make_include(&self, config: &IncludeCppConfig) -> TokenStream

Make a macro to include a given generated Rust file name. This can’t simply be calculated from get_rs_dir because of limitations in rust-analyzer.

Source

pub fn get_rs_dir(&self) -> PathBuf

Location to generate Rust files.

Source

pub fn get_include_dir(&self) -> PathBuf

Location to generate C++ header files.

Source

pub fn get_cxx_dir(&self) -> PathBuf

Location to generate C++ code.

Source

pub fn set_cargo_env_vars_for_build(&self)

From a build script, inform cargo how to set environment variables to make them available to the procedural macro.

Trait Implementations§

Source§

impl Default for FileLocationStrategy

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. 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.