Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Implement ReflectValue serialization for Duration #3318

Closed
wants to merge 2 commits into from
Closed

[Merged by Bors] - Implement ReflectValue serialization for Duration #3318

wants to merge 2 commits into from

Conversation

jcornaz
Copy link
Contributor

@jcornaz jcornaz commented Dec 13, 2021

Objective

Resolves #3277

Currenty if we try to serialize a scene that contains a Duration (which is very common, since Timer contains one), we get an error saying:

Type 'core::time::Duration' does not support ReflectValue serialization

Solution

Let Duration implement SerializeValue.

@github-actions github-actions bot added the S-Needs-Triage This issue needs to be labelled label Dec 13, 2021
@alice-i-cecile alice-i-cecile added A-Core Common functionality for all bevy apps A-Reflection Runtime information about types C-Usability A targeted quality-of-life change that makes Bevy easier to use and removed S-Needs-Triage This issue needs to be labelled labels Dec 13, 2021
@alice-i-cecile
Copy link
Member

Looks good to me. Could you do the same quick for Instant in this PR? It's not quite as immediately useful, but it's an important complement to Duration.

@jcornaz
Copy link
Contributor Author

jcornaz commented Dec 13, 2021

Could you do the same quick for Instant in this PR? It's not quite as immediately useful, but it's an important complement to Duration.

Mmm... that one is less straightforward. Because serde doesn't implement Serialize and Deserialize for Instant. And more generally, it is not that easy (or even possible?) because Instant is an opaque type.

From https://doc.rust-lang.org/stable/std/time/struct.Instant.html:

Instants are opaque types that can only be compared to one another. There is no method to get "the number of seconds" from an instant. Instead, it only allows measuring the duration between two instants (or comparing two instants).

@alice-i-cecile
Copy link
Member

Mmm... that one is less straightforward. Because serde doesn't implement Serialize and Deserialize for Instant. And more generally, it is not that easy (or even possible?) because Instant is an opaque type.

Sounds good to me. I'll keep an eye out for this when designing Bevy's timers and related work: hopefully we should never need to store instants.

@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Dec 13, 2021
@cart
Copy link
Member

cart commented Dec 29, 2021

bors r+

bors bot pushed a commit that referenced this pull request Dec 29, 2021
# Objective

Resolves #3277 

Currenty if we try to serialize a scene that contains a `Duration` (which is very common, since `Timer` contains one), we get an error saying:

> Type 'core::time::Duration' does not support ReflectValue serialization


## Solution

Let `Duration` implement `SerializeValue`.



Co-authored-by: Jonathan Cornaz <[email protected]>
@bors bors bot changed the title Implement ReflectValue serialization for Duration [Merged by Bors] - Implement ReflectValue serialization for Duration Dec 29, 2021
@bors bors bot closed this Dec 29, 2021
mockersf pushed a commit to mockersf/bevy that referenced this pull request Jan 1, 2022
# Objective

Resolves bevyengine#3277 

Currenty if we try to serialize a scene that contains a `Duration` (which is very common, since `Timer` contains one), we get an error saying:

> Type 'core::time::Duration' does not support ReflectValue serialization


## Solution

Let `Duration` implement `SerializeValue`.



Co-authored-by: Jonathan Cornaz <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Core Common functionality for all bevy apps A-Reflection Runtime information about types C-Usability A targeted quality-of-life change that makes Bevy easier to use S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Type 'core::time::Duration' does not support ReflectValue serialization
3 participants