Comments (4)
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.
I see, do you suggest adding validation before calling put
or inside Put
instance?
from cereal.
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.
Well, I guess this pretty much resolves the issue :) thank you
from cereal.
Related Issues (20)
- Support for Decimal128 HOT 1
- I can't just get the result and Builder out of Put. HOT 1
- Missing `Serialize` instance for `NonEmpty a` HOT 1
- Build error HOT 10
- Request for new release HOT 2
- Missing base Serialize instances: Identity, Const
- Upload GHC-8.8.1 changes to Hackage HOT 1
- Question about Generic serialiazation/deserialization, Not a bug (a priori) HOT 4
- [Question] Are serializations portable to other machines? HOT 2
- gPut depends on the nesting structure of :+:
- Missing getters for Int putters
- lookAhead and bytesRead HOT 2
- doc issue HOT 2
- Missing `instance Serialize Void`
- Cannot be built with GHC 9.2.0.20210821 HOT 2
- Deserialization of Ratios with 0 denominator
- Export an `eof` getter that spits out the remaining bytestring HOT 5
- Build failure with GHC 9.4 HOT 3
- combining isEmpty with many causes an internal error HOT 2
- fails to build with ghc-9.6.3 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cereal.