Comments (10)
Why is it big endian by default anyway?
from bincode.
There's a few equally valid choices here; I personally think it's also important to be able to serialise with native endianness (use case: serialising a sequence of structs to disk and them reading them back via python/numpy or other process on the same box/cpu which would use the native byte order by default). byteorder
already provides NativeEndian
so that's easy.
Off top of my head, I would probably expect a binary serialisation library to use native byte order unless explicit endianness is specified by the user. This has most chances to work for careless cross-process communication. Second best would be little endian since that's what all Intel CPUs are... most unexpected would probably be big endian (for general-purpose encoding/decoding, that is).
I wouldn't mind having to provide endianness explicitly though, until 213 lands (if it lands); then it's a separate choice of selecting a sensible default :)
from bincode.
@cmr: something about network byte order. Was probably a mistake. In the next breaking change I'll likely fix it.
from bincode.
Looking forward to this as well. It looks like RFC 213 is a good while from being stabilised due to uncertainty re: integer fallback, so maybe providing an explicit endianness parameter (or type parameter), or even encode_be()
, encode_le()
would be great.
from bincode.
What would you think about having the default methods use big-endian, but have an module with endian-choice methods?
once 213 lands, it would be easy to deprecate that module, but in the meantime, it wouldn't hurt new users that don't care about endianness.
Or maybe choosing endianness isn't that big of a deal and we should just make everyone do it until default method parameters land?
from bincode.
I'd be using this too. I'd be happy with a temporary separate module.
from bincode.
Honestly I'm leaning towards explicit endianness right now. It doesn't seem like a huge hit to usability and makes it pretty obvious what's going on.
from bincode.
I'm just hoping that I don't get hit with bugs from people using different endianness for encoding and decoding...
from bincode.
In C, there is a slight advantage to using "network byte order" aka big endian because you must write every endian conversion manually, so if you leave one out then it breaks on your little endian development machine, but this does not apply to Rust. In Rust, one should probably specify the endianness in a type parameter, not sure all type parameters accept defaults though.
from bincode.
cf. #103
from bincode.
Related Issues (20)
- Feature request: predetermined U8/U16/U32/U64 array lengths HOT 1
- UnexpectedVariant on encoded data HOT 6
- Trying to implement Decode and Encode on an ArrayVec from tinyvec!
- Improved encoding and decoding speed of Vec<u8> HOT 3
- Modify an Existing Configuration HOT 3
- enum is encoded as Option, but cannot be decoded HOT 1
- Feature Request: Enums as number HOT 1
- Bincode 2 release HOT 8
- deserialize_in_place equivalent for bincode 2.0 HOT 1
- Panic/memory allocation of x bytes failed with 1.3.3 version of bincode HOT 3
- Why does deserializing slightly different structs from the same bytes work? HOT 2
- Saving a Configuration in a Generic Variable HOT 1
- `get_byte_buffer` equivalent in bincode 2? HOT 4
- Deserialize external tag to separate type variable HOT 1
- Arc/Rc handling clarification HOT 1
- Is there a way to patch 1.x? HOT 1
- Add codec support for chrone HOT 3
- Unclear why serialized_size() yields different results HOT 1
- Does bincode guarantee a 1:1 relationship between encodings and values? HOT 3
- bincode::de::Deserializer::with_reader() doesn't seem to work 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 bincode.