base/notifiers.rs
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
5use crate::descriptor::AsRawDescriptor;
6
7pub 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
13impl ReadNotifier for std::fs::File {
14 fn get_read_notifier(&self) -> &dyn AsRawDescriptor {
15 self
16 }
17}
18
19pub 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}