File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ project adheres to [Semantic Versioning](https://semver.org/).
88## [ Unreleased]
99### Added
1010* Added conversions between ` DataBits ` , ` StopBits ` types and their numeric representations
11+ * Added ` FromStr ` implementation for ` FlowControl `
1112### Changed
1213### Fixed
1314* Fixes a bug where ` available_ports() ` returned disabled devices on Windows.
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ use std::convert::From;
3636use std:: error:: Error as StdError ;
3737use std:: fmt;
3838use std:: io;
39+ use std:: str:: FromStr ;
3940use std:: time:: Duration ;
4041
4142#[ cfg( unix) ]
@@ -284,6 +285,19 @@ impl fmt::Display for FlowControl {
284285 }
285286}
286287
288+ impl FromStr for FlowControl {
289+ type Err = ( ) ;
290+
291+ fn from_str ( s : & str ) -> core:: result:: Result < Self , Self :: Err > {
292+ match s {
293+ "None" | "none" | "n" => Ok ( FlowControl :: None ) ,
294+ "Software" | "software" | "SW" | "sw" | "s" => Ok ( FlowControl :: Software ) ,
295+ "Hardware" | "hardware" | "HW" | "hw" | "h" => Ok ( FlowControl :: Hardware ) ,
296+ _ => Err ( ( ) ) ,
297+ }
298+ }
299+ }
300+
287301/// Specifies which buffer or buffers to purge when calling [`clear`]
288302///
289303/// [`clear`]: trait.SerialPort.html#tymethod.clear
You can’t perform that action at this time.
0 commit comments