Open evanpurkhiser opened 4 years ago
I think you can try to modify https://github.com/stellar/js-xdr/blob/c58bbdc2b1c376d447208ba1ff847846b6c369e6/src/io-mixin.js#L18 a bit, like:
const cursor = new Cursor(buffer); // js-xdr Cursor
const result = acceptedReply.read(cursor);
const pos = cursor.tell() // bytes read
// if SUCCESS:
procedureSpecific = buffer.slice(pos)
Is your feature request related to a problem? Please describe. I'm implementing the ONC-RPC protocol using this XDR library. Part of the spec has structs that represent headers for arbitrary data requests and responses, thus I need a way to specify a type that basically says 'the rest of the data in the buffer', like
varOpaque
but without the length header.For example, the struct:
The
procedure-specific results start here
is where the rest response of the rpc call lives. But how can I access that after usingfromXDR
?Describe the solution you'd like
Here's what I've hacked together: https://github.com/EvanPurkhiser/prolink-typescript/blob/957918208b0399ceaa1d6978ae23c7d3415b8436/src/nfs/xdr.ts#L3-L18
Then the union definition looks like this
https://github.com/EvanPurkhiser/prolink-typescript/blob/957918208b0399ceaa1d6978ae23c7d3415b8436/src/nfs/xdr.ts#L84-L95
Describe alternatives you've considered Alternatively some access to the cursor could potentially be OK, but it would be nice to get the data back as part of the result object