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

Add a method to RpcModule that transforms the module into a RpcModule<()>, i.e. removes the context. #660

Merged
merged 6 commits into from
Jan 21, 2022

Conversation

dvdplm
Copy link
Contributor

@dvdplm dvdplm commented Jan 19, 2022

Closes #558

…ule into a `RpcModule<()>`, i.e. removes the context.
@dvdplm dvdplm requested a review from a team as a code owner January 19, 2022 10:47
@dvdplm dvdplm self-assigned this Jan 19, 2022
@niklasad1 niklasad1 requested a review from maciejhirsz January 20, 2022 08:28
Comment on lines 34 to 40
fn assert_type<T: 'static, Expected: 'static>(_expected: &Expected, explain: Option<&'static str>) {
use core::any::TypeId;
match explain {
None => assert_eq!(TypeId::of::<T>(), TypeId::of::<Expected>()),
Some(explain) => assert_eq!(TypeId::of::<T>(), TypeId::of::<Expected>(), "{}", explain),
}
}
Copy link
Collaborator

@jsdw jsdw Jan 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it's better to move this check to compile-time? ie:

fn assert_type<Expected>(_expected: &Expected) {}

Usage (compile error if types don't match):

assert_type::<SomeType>(&some_value);

This becomes quite small and could be inlined into the macro if preferred!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cheers!

@dvdplm dvdplm changed the title Add a method to RpcModule, decontextualize, that transforms the module into a RpcModule<()>, i.e. removes the context. Add a method to RpcModule that transforms the module into a RpcModule<()>, i.e. removes the context. Jan 21, 2022
Copy link
Contributor

@maciejhirsz maciejhirsz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one simple grumble :)

core/src/server/rpc_module.rs Outdated Show resolved Hide resolved
@dvdplm dvdplm merged commit c0f343d into master Jan 21, 2022
@dvdplm dvdplm deleted the dp-decontextualize-rpcmodule branch January 21, 2022 13:21
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.

Make it trivial to convert a RpcModule<Something> to RpcModule<()>
4 participants