@@ -326,7 +326,7 @@ pub struct SerialPortBuilder {
326
326
/// Number of bits to use to signal the end of a character
327
327
stop_bits : StopBits ,
328
328
/// Amount of time to wait to receive data before timing out
329
- timeout : Duration ,
329
+ timeout : Option < Duration > ,
330
330
}
331
331
332
332
impl SerialPortBuilder {
@@ -375,7 +375,7 @@ impl SerialPortBuilder {
375
375
/// Set the amount of time to wait to receive data before timing out
376
376
#[ must_use]
377
377
pub fn timeout ( mut self , timeout : Duration ) -> Self {
378
- self . timeout = timeout;
378
+ self . timeout = Some ( timeout) ;
379
379
self
380
380
}
381
381
@@ -459,7 +459,7 @@ pub trait SerialPort: Send + io::Read + io::Write {
459
459
fn stop_bits ( & self ) -> Result < StopBits > ;
460
460
461
461
/// Returns the current timeout.
462
- fn timeout ( & self ) -> Duration ;
462
+ fn timeout ( & self ) -> Option < Duration > ;
463
463
464
464
// Port settings setters
465
465
@@ -485,7 +485,7 @@ pub trait SerialPort: Send + io::Read + io::Write {
485
485
fn set_stop_bits ( & mut self , stop_bits : StopBits ) -> Result < ( ) > ;
486
486
487
487
/// Sets the timeout for future I/O operations.
488
- fn set_timeout ( & mut self , timeout : Duration ) -> Result < ( ) > ;
488
+ fn set_timeout ( & mut self , timeout : Option < Duration > ) -> Result < ( ) > ;
489
489
490
490
// Functions for setting non-data control signal pins
491
491
@@ -647,7 +647,7 @@ impl<T: SerialPort> SerialPort for &mut T {
647
647
( * * self ) . stop_bits ( )
648
648
}
649
649
650
- fn timeout ( & self ) -> Duration {
650
+ fn timeout ( & self ) -> Option < Duration > {
651
651
( * * self ) . timeout ( )
652
652
}
653
653
@@ -671,7 +671,7 @@ impl<T: SerialPort> SerialPort for &mut T {
671
671
( * * self ) . set_stop_bits ( stop_bits)
672
672
}
673
673
674
- fn set_timeout ( & mut self , timeout : Duration ) -> Result < ( ) > {
674
+ fn set_timeout ( & mut self , timeout : Option < Duration > ) -> Result < ( ) > {
675
675
( * * self ) . set_timeout ( timeout)
676
676
}
677
677
@@ -812,7 +812,7 @@ pub fn new<'a>(path: impl Into<std::borrow::Cow<'a, str>>, baud_rate: u32) -> Se
812
812
flow_control : FlowControl :: None ,
813
813
parity : Parity :: None ,
814
814
stop_bits : StopBits :: One ,
815
- timeout : Duration :: from_millis ( 0 ) ,
815
+ timeout : None ,
816
816
}
817
817
}
818
818
0 commit comments