summary refs log tree commit diff
path: root/sys_util/src/raw_fd.rs
blob: 05a762f28984040dc74280bf5651bee37e84940e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// Copyright 2019 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Utility file to provide a slightly safer Fd type that cannot be confused with c_int.
// Also useful for situations that require something that is `AsRawFd` but
// where we don't want to store more than the fd.

use std::os::unix::io::{AsRawFd, RawFd};

pub struct Fd(pub RawFd);
impl AsRawFd for Fd {
    fn as_raw_fd(&self) -> RawFd {
        self.0
    }
}