Skip to content
This repository has been archived by the owner on Oct 18, 2022. It is now read-only.

Export the parser for direct usage #54

Open
belak opened this issue Jan 1, 2020 · 4 comments
Open

Export the parser for direct usage #54

belak opened this issue Jan 1, 2020 · 4 comments

Comments

@belak
Copy link

belak commented Jan 1, 2020

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.

@belak belak changed the title Export the parser for non-http transports Export the parser for direct usage Jan 1, 2020
@belak
Copy link
Author

belak commented Jan 1, 2020

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.

@jonas-schievink
Copy link
Owner

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.

@belak
Copy link
Author

belak commented Jan 1, 2020

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.

@belak
Copy link
Author

belak commented Jan 1, 2020

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants