-
Notifications
You must be signed in to change notification settings - Fork 290
refactor(crypto): Make the room key importing logic more generic #5041
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
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5041 +/- ##
==========================================
- Coverage 85.85% 85.85% -0.01%
==========================================
Files 325 325
Lines 35855 35864 +9
==========================================
+ Hits 30784 30790 +6
- Misses 5071 5074 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, one question.
|
||
async fn import_sessions_impl<T>( | ||
&self, | ||
room_keys: Vec<T>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be IntoIter<T>
or something, to avoid the collect()
above when we call it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kinda, though it can't be just that, because we have a room_keys.len()
call.
Which then makes all of the trait bounds even more complex.
The other option is to remove the len()
call, but then our progress listener doesn't work anymore.
Don't think it's worth it to avoid this collect()
call, after all, allocating a vector of references isn't that big of a deal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, agree it's fine as-is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Or pass in the length?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Or pass in the length?)
That sounds like it would be a bit of a clunky API, not terrible but clunky enough for me to rather take the allocation.
The only reason why we take a Vec<&Foo>
vs a Vec<Foo>
is so we can gather info about the specific key in the error branch if creating a InboundGroupSession
fails.
Perhaps gathering the info before the try_into()
call consumes the key would be the wiser choice if we really want to avoid the allocation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't mind either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, let's keep the allocation, if we change our mind I think gathering the info before the consumption of the key would be the way to go.
Part of #4513 and necessary for #4989.
Making this generic right now is a bit of a no-op, but eventually we'll also import the
HistoricRoomKey
type which requires this to be generic.