/src/crosvm/devices/src/serial/sys/linux.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 std::io; |
6 | | |
7 | | use base::Event; |
8 | | use base::FileSync; |
9 | | use base::RawDescriptor; |
10 | | use hypervisor::ProtectionType; |
11 | | |
12 | | use crate::serial_device::SerialInput; |
13 | | use crate::serial_device::SerialOptions; |
14 | | use crate::sys::serial_device::SerialDevice; |
15 | | use crate::Serial; |
16 | | |
17 | | // TODO(b/234469655): Remove type alias once ReadNotifier is implemented for |
18 | | // PipeConnection. |
19 | | pub(crate) type InStreamType = Box<dyn SerialInput>; |
20 | | |
21 | | impl SerialDevice for Serial { |
22 | | /// Constructs a Serial device ready for input and output. |
23 | | /// |
24 | | /// The stream `input` should not block, instead returning 0 bytes if are no bytes available. |
25 | 0 | fn new( |
26 | 0 | _protection_type: ProtectionType, |
27 | 0 | interrupt_evt: Event, |
28 | 0 | input: Option<Box<dyn SerialInput>>, |
29 | 0 | out: Option<Box<dyn io::Write + Send>>, |
30 | 0 | _sync: Option<Box<dyn FileSync + Send>>, |
31 | 0 | options: SerialOptions, |
32 | 0 | _keep_rds: Vec<RawDescriptor>, |
33 | 0 | ) -> Serial { |
34 | 0 | Serial::new_common(interrupt_evt, input, out, options.out_timestamp) |
35 | 0 | } |
36 | | } |