@@ -326,7 +326,7 @@ pub struct SerialPortBuilder {
326326 /// Number of bits to use to signal the end of a character
327327 stop_bits : StopBits ,
328328 /// Amount of time to wait to receive data before timing out
329- timeout : Duration ,
329+ timeout : Option < Duration > ,
330330}
331331
332332impl SerialPortBuilder {
@@ -375,7 +375,7 @@ impl SerialPortBuilder {
375375 /// Set the amount of time to wait to receive data before timing out
376376 #[ must_use]
377377 pub fn timeout ( mut self , timeout : Duration ) -> Self {
378- self . timeout = timeout;
378+ self . timeout = Some ( timeout) ;
379379 self
380380 }
381381
@@ -459,7 +459,7 @@ pub trait SerialPort: Send + io::Read + io::Write {
459459 fn stop_bits ( & self ) -> Result < StopBits > ;
460460
461461 /// Returns the current timeout.
462- fn timeout ( & self ) -> Duration ;
462+ fn timeout ( & self ) -> Option < Duration > ;
463463
464464 // Port settings setters
465465
@@ -485,7 +485,7 @@ pub trait SerialPort: Send + io::Read + io::Write {
485485 fn set_stop_bits ( & mut self , stop_bits : StopBits ) -> Result < ( ) > ;
486486
487487 /// 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 < ( ) > ;
489489
490490 // Functions for setting non-data control signal pins
491491
@@ -647,7 +647,7 @@ impl<T: SerialPort> SerialPort for &mut T {
647647 ( * * self ) . stop_bits ( )
648648 }
649649
650- fn timeout ( & self ) -> Duration {
650+ fn timeout ( & self ) -> Option < Duration > {
651651 ( * * self ) . timeout ( )
652652 }
653653
@@ -671,7 +671,7 @@ impl<T: SerialPort> SerialPort for &mut T {
671671 ( * * self ) . set_stop_bits ( stop_bits)
672672 }
673673
674- fn set_timeout ( & mut self , timeout : Duration ) -> Result < ( ) > {
674+ fn set_timeout ( & mut self , timeout : Option < Duration > ) -> Result < ( ) > {
675675 ( * * self ) . set_timeout ( timeout)
676676 }
677677
@@ -812,7 +812,7 @@ pub fn new<'a>(path: impl Into<std::borrow::Cow<'a, str>>, baud_rate: u32) -> Se
812812 flow_control : FlowControl :: None ,
813813 parity : Parity :: None ,
814814 stop_bits : StopBits :: One ,
815- timeout : Duration :: from_millis ( 0 ) ,
815+ timeout : None ,
816816 }
817817}
818818
0 commit comments