我试图通过FFI在Rust中使用"xerces-c"而没有成功.在C++中,我会编写以下代码来使用它:
XMLPlatformUtils::Initialize();
{
XercesDOMParser domParser;
ParserErrorHandler parserErrorHandler;
domParser.setErrorHandler(&parserErrorHandler);
domParser.setDoSchema(true);
domParser.setValidationSchemaFullChecking(true);
domParser.parse(xmlFilePath.c_str());
if(domParser.getErrorCount() != 0) {
// ...
}
}
XMLPlatformUtils::Terminate();
Run Code Online (Sandbox Code Playgroud)
如何在Rust中使用这些"复杂"数据类型?我找到了许多导出/创建FFI以在其他语言中使用它的示例,但没有在Rust中使用复杂类型.
extern crate libc;
#[link(name = "xerces-c")]
extern {
// How do i have to implement the constructor here?
}
Run Code Online (Sandbox Code Playgroud)