Git Product home page Git Product logo

Comments (4)

elliottt avatar elliottt commented on September 15, 2024

Hi,

Is your worry here that the default implementation of put for a ByteString will encode its length as Word64? If so, you can just use putByteString to put directly to the output buffer, choosing your own mechanism for length encoding.

If your worry is that ByteString uses a platform-dependent representation for lengths that could be Int32 or Int64, then I would suggest just doing the validation before running the rendering operation, as there's not really a good way to tie the length of a ByteString to its type, currently.

I'm reluctant to add error checking to the Put monad, as it's already slower than Get :)

from cereal.

superbobry avatar superbobry commented on September 15, 2024

I see, do you suggest adding validation before calling put or inside Put instance?

from cereal.

elliottt avatar elliottt commented on September 15, 2024

I would do validation before. I'd also advise against using the Serialize class if you're parsing something that's not already a haskell value. The Serialize class makes it easy to dump a haskell value out to be read back in later on, but it makes assumptions about how data gets parsed and rendered that aren't always consistent with other formats. Falling back on the primitives that are exported by Data.Serialize.Get and Data.Serialize.Put gives you much more control over how your data is processed.

from cereal.

superbobry avatar superbobry commented on September 15, 2024

Well, I guess this pretty much resolves the issue :) thank you

from cereal.

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.