1 // Copyright 2019 The Chromium OS Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Utility file to provide a slightly safer Fd type that cannot be confused with c_int. 6 // Also useful for situations that require something that is `AsRawFd` but 7 // where we don't want to store more than the fd. 8 9 use std::os::unix::io::{AsRawFd, RawFd}; 10 11 pub struct Fd(pub RawFd); 12 impl AsRawFd for Fd { as_raw_fd(&self) -> RawFd13 fn as_raw_fd(&self) -> RawFd { 14 self.0 15 } 16 } 17