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

Implement (De)Serialization for Pinned Smart Pointers #733

Merged
merged 2 commits into from
Apr 24, 2024
Merged

Implement (De)Serialization for Pinned Smart Pointers #733

merged 2 commits into from
Apr 24, 2024

Conversation

Astralchroma
Copy link
Contributor

Implements SerializeAs and DeserializeAs for Pin<Box<T>>, Pin<Rc<T>>, and Pin<Arc<T>>

@Astralchroma
Copy link
Contributor Author

Astralchroma commented Apr 20, 2024

Seems the lints are bugged and are flagging the macros as unused when they are in fact used. I'll go ahead and add an #[allow(unused_macros)] for now.

Copy link

codecov bot commented Apr 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 66.55%. Comparing base (f4145e3) to head (04de4ce).
Report is 14 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #733      +/-   ##
==========================================
+ Coverage   66.49%   66.55%   +0.06%     
==========================================
  Files          38       38              
  Lines        2468     2473       +5     
==========================================
+ Hits         1641     1646       +5     
  Misses        827      827              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Astralchroma Astralchroma changed the title Implement (De)Seralization for Pinned Smart Pointers Implement (De)Serialization for Pinned Smart Pointers Apr 20, 2024
@jonasbb
Copy link
Owner

jonasbb commented Apr 22, 2024

Hi, thank you for submitting the PR. Everything looks good here. I extended the SerializeAs side with support for Pin<&'a T> and Pin<&'a mut T>.

I wonder if it is possible to support any Pin<T>, not just with specific pointer types. Pin::as_ref almost looks like it could work, but then is also return Deref::Target and I couldn't figure out how to make that work. On the deserialization side we need the well-known pointer types, since only they have safe conversions to Pin.

I leave this PR open for a day or two, in case you have an idea how to extend the serialization side, otherwise this looks good to merge.

@Astralchroma
Copy link
Contributor Author

Yea, honestly not sure about how to go about extending it to work using Deref stuff. Had a go at it myself and couldn't really get very far with it. Might come back to it later as it seems like an interesting idea, however I'm just going to leave it for now I think.

@jonasbb jonasbb merged commit 167e865 into jonasbb:master Apr 24, 2024
22 checks passed
@Astralchroma Astralchroma deleted the pin branch July 7, 2024 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants