/src/crosvm/base/src/notifiers.rs
Line | Count | Source |
1 | | // Copyright 2022 The ChromiumOS Authors |
2 | | // Use of this source code is governed by a BSD-style license that can be |
3 | | // found in the LICENSE file. |
4 | | |
5 | | use crate::descriptor::AsRawDescriptor; |
6 | | |
7 | | pub trait ReadNotifier { |
8 | | /// Gets a descriptor that can be used in EventContext to wait for events to be available (e.g. |
9 | | /// to avoid receive_events blocking). |
10 | | fn get_read_notifier(&self) -> &dyn AsRawDescriptor; |
11 | | } |
12 | | |
13 | | impl ReadNotifier for std::fs::File { |
14 | 0 | fn get_read_notifier(&self) -> &dyn AsRawDescriptor { |
15 | 0 | self |
16 | 0 | } |
17 | | } |
18 | | |
19 | | pub trait CloseNotifier { |
20 | | /// Gets a descriptor that can be used in EventContext to wait for the closed event. |
21 | | fn get_close_notifier(&self) -> &dyn AsRawDescriptor; |
22 | | } |