我已经使用Rust-embed设置了以下基础架构:
板条板A:
- 构建
dylib
( .so
file),该 file)使用派生的宏来在编译时间加载文件到结构。
#[derive(RustEmbed)]
#[folder = "./src"]
struct Asset;
代码和更多文档在这里:
在这种情况下,它将所有文件加载到该板条箱的 ./ src
中。
板条板B:
- 从板条箱中加载构建的
.so
使用 libloading
的文件,其中包括以下类型: type loadAssetAssetFunc = fn() - >资产;
- 应该能够调用
资产:: get
( get
在 Rustembed
derive acro中定义),
但是即使我我正在返回资产
在结构或 box
中使用 ./ src
文件,因此它正在使用struct 资产
在板条板B中,它也使用了衍生宏,并且在板条箱中不使用 Asset
的构造,该板条箱中加载了该板条箱中的文件。我如何确保它使用 Asset
a而不是b?
I have setup the following infrastructure using rust-embed:
Crate A:
- Builds a
dylib
(.so
file) which uses a derive macro to load files at compile time to a struct.
#[derive(RustEmbed)]
#[folder = "./src"]
struct Asset;
Code and more documentation is here: https://github.com/pyrossh/rust-embed#documentation
In this case it loads all the files within ./src
of that crate.
Crate B:
- Loads the built
.so
file from crate A using libloading
with the following type: type LoadAssetFunc = fn() -> Asset;
- Should be able to call
Asset::get
(get
is defined in the RustEmbed
derive macro)
However even if I am returning Asset
within a struct or a Box
it'll use the ./src
files within the current crate, so it is using the struct of Asset
within Crate B which also uses the derive macro and it is not using the struct of Asset
within Crate A which loaded the files within that crate. How can I make sure it is using Asset
of Crate A and not B?
发布评论