Open belak opened 4 years ago
I found Transport and attempted to implement it for tokio::net::UnixStream, but it gets pretty frustrating to deal with non async functions in async contexts... especially when Transport requires you to write (which would be async under tokio) and return something that can be read from. Having the parse_response function exported would let libraries handle reading and writing and simply defer to this package for the encoding and decoding.
Yes, Transport
is supposed to cover this use case. I have accepted PRs that expose internal functions in the past, but a better approach is to invest some time in improving the existing building blocks in this crate. Right now it doesn't have any support for async operations, but you can still use it via spawn_blocking
(or by using a scheduler that isn't sensitive to blocking).
I'm definitely interested in adding async support provided that it is runtime-independent, so feel free to do the necessary design work and open a PR.
Unfortunately, being new to Rust, I have no idea what a good async API would look like here. Maybe adding an AsyncTransport type?
Just exposing a function to parse the response into a value would do everything I need... and it already exists, just not exported. It also lines up with write_to_xml as the other half of that equation.
I’d be happy to put the work in to code it, but I’d like to avoid wasting a bunch of time designing and coding an API that isn’t idiomatic which seems likely given my newness to the language.
I've been working with this package for serialization and deserialization over an scgi transport, but that means I need to serialize and deserialize to something other than http. Thankfully, write_to_xml is implemented when http is disabled, but there's no way that I could currently find to deserialize from an xml document without using the http transport because the parser package doesn't appear to be exported.