# Getting descriptor of std::fs::File

**URL:** <https://internals.rust-lang.org/t/getting-descriptor-of-std-fs-file/2912>\
**Category:** Uncategorized\
**Created:** [November 17, 2015, 3:50pm UTC](https://internals.rust-lang.org/t/getting-descriptor-of-std-fs-file/2912 "2015-11-17T15:50:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![luxvio](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/luxvio/32/1236_2.png) [@luxvio](https://internals.rust-lang.org/u/luxvio)\
**Post date:** [November 17, 2015, 3:50pm UTC](https://internals.rust-lang.org/t/getting-descriptor-of-std-fs-file/2912/1 "2015-11-17T15:50:20Z")

</div>

Hi !  
I’ve been looking forward to make a crate wrapping [capsicum](https://www.freebsd.org/cgi/man.cgi?query=capsicum&sektion=4) for FreeBSD (even though technically there’s [https://github.com/google/capsicum-linux](https://github.com/google/capsicum-linux) too), and I couldn’t find a way to extract the file descriptor off a `std::fs::File` or any struct that encapsulates that kind of data.

I’ve searched and found about a native crate, or about using libc, etc. But the idea is not to have to use raw syscalls, but rather remain compatible with the standard interfaces with the chance to “attach hints” to the descriptors to allow certain actions or not (letting Result do his normal thing)

¿Is there any chance?

Thanks for reading !  
Regards

---

<div class="post-metadata">

**Author:** ![DanielKeep](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/danielkeep/32/1332_2.png) [@DanielKeep](https://internals.rust-lang.org/u/DanielKeep)\
**Post date:** [November 17, 2015, 3:53pm UTC](https://internals.rust-lang.org/t/getting-descriptor-of-std-fs-file/2912/2 "2015-11-17T15:53:54Z")

</div>

You mean `std::os::unix::io::{` [`AsRawFd`](http://doc.rust-lang.org/std/os/unix/io/trait.AsRawFd.html) `,` [`IntoRawFd`](http://doc.rust-lang.org/std/os/unix/io/trait.IntoRawFd.html) `}` ?

---

<div class="post-metadata">

**Author:** ![luxvio](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/luxvio/32/1236_2.png) [@luxvio](https://internals.rust-lang.org/u/luxvio)\
**Post date:** [November 17, 2015, 3:59pm UTC](https://internals.rust-lang.org/t/getting-descriptor-of-std-fs-file/2912/3 "2015-11-17T15:59:00Z")

</div>

Amazing, thanks !! I’ll investigate those 😃

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/system/32/14092_2.png) [@system](https://internals.rust-lang.org/u/system)\
**Post date:** [March 25, 2019, 8:25am UTC](https://internals.rust-lang.org/t/getting-descriptor-of-std-fs-file/2912/4 "2019-03-25T08:25:28Z")

</div>

Closed on March 25, 2019, 8:25am UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
