You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I find the current way of using strings to construct a MavConnection implementer through mavlink::connect(..) a bit awkward. It feels more like an application-level interface and not a library level interface, making it harder to build on top of the existing connection code or just use e.g. the serial implementation directly.
What I propose would include:
Make types which encode the description/configuration of a connection
Expose the individual MavConnection implementations for direct creation.
I imagine it could look something like this:
// in: mavlink-core/connectionpubtraitConnectable<M:Message>whereSelf:Sized{fnconnect(&self) -> io::Result<Box<dynMavConnection<M> + Sync + Send>>;}// in: mavlink-core/connection/serialpubstructSerialConfig{pubport:String,pubbaud:usize,}impl<M:Message>Connectable<M>forSerialConfig{// impl}// in: mavlink-core/connection/tcppubstructTcpConfig{pubaddr:SocketAddr,pubout:bool,}impl<M:Message>Connectable<M>forTcpConfig{// impl}// And so on..
which would make it fairly easy to implement a string-parser like:
match argument.split_whitespace().collect::<Vec<_>>().as_slice(){["serial", port, baud] => SerialConfig{port: port.to_string(),baud: baud.parse().ok()?,}.connect()?,[conn @ "tcpin" | "tcpout", addr] => TcpConfig{addr:SocketAddr::from_str(port).ok()?,out:if conn == &"tcpout"{true}else{false},}.connect()?,// and so on..
_ => None,// some error}
What do you think?
The text was updated successfully, but these errors were encountered:
I find the current way of using strings to construct a
MavConnection
implementer throughmavlink::connect(..)
a bit awkward. It feels more like an application-level interface and not a library level interface, making it harder to build on top of the existing connection code or just use e.g. the serial implementation directly.What I propose would include:
MavConnection
implementations for direct creation.I imagine it could look something like this:
which would make it fairly easy to implement a string-parser like:
What do you think?
The text was updated successfully, but these errors were encountered: