feat: add port_info() default method to SerialPort trait - #339
Conversation
|
Should this target the playground-5.0 branch instead of main, given that it touches the SerialPort trait? i read some old pr where you listed it specific point |
|
Thank you for starting this draft PR @KaustubhOG! Please see my comment #276 (comment) in the original issue. Regarding this PR: Enumerating all ports for identifying the details of a single one looks somewhat like a brute force approach. Sure, this is what we could do with just the current public API. Did you have a look into how information for a certain port could be fetched with the enumeration mechanisms we are using (like libudev, macOS' I/O registry, |
Closes #276
Problem
There is currently no way to retrieve
SerialPortInfofrom an opendyn SerialPortwithout callingavailable_ports()manually and searching by name.Solution
Add a default
port_info()method to theSerialPorttrait. The implementation callsself.name(), enumerates available ports, and returns the matchingSerialPortInfoentry.Since it is a default method, all existing implementors (
TTYPort,COMPort, and the&mut Tblanket impl) get it for free with no changes required on their end.Returns
Errif:available_ports()failsNotes
if a faster implementation is needed (e.g. caching info at open time)