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. new( _protection_type: ProtectionType, interrupt_evt: Event, input: Option<Box<dyn SerialInput>>, out: Option<Box<dyn io::Write + Send>>, _sync: Option<Box<dyn FileSync + Send>>, options: SerialOptions, _keep_rds: Vec<RawDescriptor>, ) -> Serial25 fn new( 26 _protection_type: ProtectionType, 27 interrupt_evt: Event, 28 input: Option<Box<dyn SerialInput>>, 29 out: Option<Box<dyn io::Write + Send>>, 30 _sync: Option<Box<dyn FileSync + Send>>, 31 options: SerialOptions, 32 _keep_rds: Vec<RawDescriptor>, 33 ) -> Serial { 34 Serial::new_common(interrupt_evt, input, out, options.out_timestamp) 35 } 36 } 37