我试图在Rust中通过FFI使用“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();
我该如何在Rust中使用这些“复杂”数据类型?我发现很多示例可以导出/创建FFI以在其他语言中使用它,但没有一种方法可以在Rust内部使用复杂类型。
extern crate libc;
#[link(name = "xerces-c")]
extern {
// How do i have to implement the constructor here?
}