sys_util/
raw_fd.rs

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
9use std::os::unix::io::{AsRawFd, RawFd};
10
11pub struct Fd(pub RawFd);
12impl AsRawFd for Fd {
13    fn as_raw_fd(&self) -> RawFd {
14        self.0
15    }
16}