Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add position method for encoder/decoder #218

Open
wildart opened this issue Oct 5, 2022 · 0 comments
Open

Add position method for encoder/decoder #218

wildart opened this issue Oct 5, 2022 · 0 comments

Comments

@wildart
Copy link

wildart commented Oct 5, 2022

Is it possible to abstract position and perform it on encoder/decoder object instead of io property? Its assumed that io object type would have a position implemented, but for socket types (pipe & network) it's not the case.

Here is an example of a generated encoder code

function PB.encode(e::PB.AbstractProtoEncoder, x::Point)
    initpos = position(e.io)
    x.latitude != zero(Int32) && PB.encode(e, 1, x.latitude)
    x.longitude != zero(Int32) && PB.encode(e, 2, x.longitude)
    return position(e.io) - initpos
end

If I want to implement a socket-based encoder I may need to handle position requests to encoder itself which would handle some additional metadata exchange to get the message size or some terminator by wire to estimate a position within protobuf data stream.

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

No branches or pull requests

1 participant