1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Copyright 2022 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

use crate::descriptor::AsRawDescriptor;

pub trait ReadNotifier {
    /// Gets a descriptor that can be used in EventContext to wait for events to be available (e.g.
    /// to avoid receive_events blocking).
    fn get_read_notifier(&self) -> &dyn AsRawDescriptor;
}

impl ReadNotifier for std::fs::File {
    fn get_read_notifier(&self) -> &dyn AsRawDescriptor {
        self
    }
}

pub trait CloseNotifier {
    /// Gets a descriptor that can be used in EventContext to wait for the closed event.
    fn get_close_notifier(&self) -> &dyn AsRawDescriptor;
}