如何从Rust中的特定原始文件描述符读取? [英] How can I read from a specific raw file descriptor in Rust?
问题描述
编者注:此问题适用于1.0之前的Rust版本.一些答案已更新为涵盖Rust 1.0或更高版本,但并非全部.
Editor's note: This question is for a version of Rust prior to 1.0. Some answers have been updated to cover Rust 1.0 or up, but not all.
我正在Rust中编写一个systemd套接字激活的服务. systemd正在将我的进程交给一个打开的文件描述符.
I am writing a systemd socket activated service in Rust. My process is being handed an open file descriptor by systemd.
是否有使用原始文件描述符的Rust IO函数?
Are there any Rust IO functions that take a raw file descriptor?
我每天晚上都在Rust 1.0之前使用Rust.
I'm using a Rust nightly before Rust 1.0.
推荐答案
I think right now your best bet is probably using the libc crate for working with raw file descriptors.
FileDesc
向私有范围的移动是几个月前运行时删除的结果.有关更多上下文,请参见此 RFC . std::os::unix
当前具有类型Fd
,我相信长远的想法是在该模块中公开更多特定于平台的功能.
The movement of FileDesc
to private scope was fallout from the runtime removal a few months back. See this RFC for some more context. std::os::unix
currently has the type Fd
, and I believe the long term idea is to expose more of the platform-specific functionality in that module.
这篇关于如何从Rust中的特定原始文件描述符读取?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!