我很难 . 但是,现在,我试图为librsync写一个绑定,并且它的一些函数希望你传递一个打开的文件句柄(C中的 FILE*
) .
对于原始类型,'s a straightforward way to pass them into C, (the same for pointers to primitive types). And, to be clear, I' m意识到 libc
crate实现 fopen
,这反过来给了我一个 mut FILE*
(最终会完成这项工作) . 但是,我想知道Rust标准库中是否有一些东西给我一个 FILE*
传递给 librsync
- 也许类似于 std::ffi::CString
.
1 回答
你当然可以使用
RawFd
,转换并用它调用libc::funcs::posix88::stdio::fdopen(_, mode)
. 但这将是非常不可移植的 .