Comments (7)
- The main reason I want to introduce abi_stable into chrono, instead of purely using
#[repr(C)]
, is that it would provide a trait (StableAbi
) and provides a link of trust and the ability to check memory layout in runtime, which#[repr(C)]
does not provide. - There are no stability guarantees that chrono has to give. Let's say there's a breaking changes in memory layout, executables and dynamic libraries that replys on two different versions of chronos should detect the different memory layout in runtime using the StableAbi crate and thus prevents crashing, which is the reason I want to introduce abi_stable.
- AFAIK, in my implementation, I bounded the
StableAbi
trait to only implement on Timezone that implementsStableAbi
. - AFAIK, abi_stable is currently the only way to do this (runtime check memory layout and abi stability)
- StableAbi is implemented for
NonZero*
andOption<NonZero*>
, but not all types (those who do not guarantees a memory layout stability in rust reference) - Due to the orphan rule, I cannot implement this in anther crate, even with wrapped new types.
from chrono.
Given the lack of popularity of the abi_stable crate, I don't think we should do this. Note also that if we commit to abi_stable 0.11.x in chrono 0.4.x we can't bump abi_stable to 0.12.x or later on chrono 0.4.x because this dependency will become part of our public API.
I think your best bet would be either on using some kind of fast serialization (like postcard or rkyv) or (longer term) on the efforts to provide Rust with a more stable ABI.
from chrono.
I don't understand this request and its consequences well enough.
- What stability guarantees would we have to give around our internal representation?
- How does this work with
DateTime
, which takes a genericTimeZone
that may not come from chrono? - Is the
abi_stable
crate the way to go and getting some acceptance in the ecosystem? It has existed for 5 years, but only has 1200 downloads/day. - Is any type supported, such as
NonZero*
? - What is the difference with making some types
#[repr(C)]
? - Is this something that can't be implemented in another crate? Why not?
At present, I have created my own fork of chrono and added an "abi_stable" feature to it.
Could you point to your branch (may be unpolished)?
from chrono.
Another question. How is the safety story for abi_stable
?
Rust has an unstable ABI, this crate offers a workaround. abi_stable
has its own unsafe_code_guidelines. What transmutes or things is it doing? Has anyone vetted this crates safety? Is there a chance it may break with a future rust version?
from chrono.
How is the safety story for
abi_stable
?
This comment makes me uneasy:
😦 This would be two orders of magnitude more work than every other time that the compiler decided to break my code combined.
It shows there is nontrivial unsafety, in a way that may not agree with the opinions of the rust language/compiler.
from chrono.
This is the proposed commit: 81f0c1a
from chrono.
I agree that my use case may not be that common (putting a lot of computation and business code in dynamic library to keep the core code clean, and passing structs through ffi boundards). And I can totally understand that for that, introducing such a lesser-used crate into chrono may not be accepted.
But for those do have this use case, since Rust does not provide a stable ffi, abi_stable is by far the best solution. And it is exactly the fact that it is lesser-used, unlike serde which most of crates provide features, not many, actually very few crates provides this feature. And due to the orphan rule, I can only fork and modify structs passing through ffi boundary.
from chrono.
Related Issues (20)
- Differences between this crate and `time` HOT 12
- Properly support padding in parsers HOT 2
- Consider reverting #807 on the 0.5 branch HOT 1
- Inconsistent crate features documentation HOT 2
- `Utc::now` can fail with dates that are very far into the past/future HOT 1
- Is there a simpler way to get the current date at a specific time? HOT 3
- 0.5.x: Timezone conversion result (`LocalResult`) HOT 39
- `DateTime` equality with different `Offset`s HOT 6
- Tracking issue: Converting the API to return `Result`s HOT 11
- Deprecate all timestamp-related methods on `NaiveDateTime` HOT 1
- `TimeDelta::num_microseconds` (?)
- Panic with TZ="pBB24" HOT 1
- Deserializing DateTime from unix timestamp is not implemented, despite description HOT 1
- Ergonomic replacements for panicking APIs. HOT 11
- function Utc::now().checked_add_signed raised wrong error HOT 7
- Proper way to build a DateTime from another DateTime's Date HOT 3
- Index out of bounds: the len is 733 but the index is 798 HOT 11
- Consistently name methods that turn into another more complete type HOT 8
- Use `localtime_rz` on Android if available
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 chrono.