Giter Site home page Giter Site logo

Comments (2)

jangko avatar jangko commented on August 27, 2024

thank you for reporting this. case object/object variants is always an interesting subject for serializer library. it is tricky to do it properly automatically.

work-around: you can provide a custom deserializer for your special object, e.g:

proc unpack_type*[ByteStream](s: ByteStream, x: var FooBarMsg) =
    let numFields = s.unpack_array() # or unpack_map if you use OBJ_TO_MAP version
    let kind = MsgType(s.unpack_imp_int64())
    x = FooBarMsg(kind: kind)
    case kind:
    of MSG_FOO : s.unpack(x.foo)
    of MSG_BAR : s.unpack(x.bar)

EDIT: you can use stringify to debug the msgpack binary data.

from msgpack4nim.

dchem avatar dchem commented on August 27, 2024

@jangko thank you very much for the workaround suggestion. That works.

I agree that object variant handling is tough to implement correctly and generally, so please feel free to close the issue if you feel that it makes sense to do so.

from msgpack4nim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.