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

Hide internal macros from public interface #755

Merged
merged 1 commit into from
May 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@

#![warn(missing_docs, missing_debug_implementations, unreachable_pub)]

#[doc(hidden)]
// Macros useful internally within this crate, but not to be exposed outside of it.
#[macro_use]
pub mod macros;
mod macros;

/// Error type.
pub mod error;
Expand Down
7 changes: 3 additions & 4 deletions core/src/macros.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#[macro_export]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's this macro_export which makes the macro part of the public interface I believe.

macro_rules! cfg_feature {
($feature:literal, $($item:item)*) => {
$(
Expand All @@ -11,19 +10,19 @@ macro_rules! cfg_feature {

macro_rules! cfg_client {
($($item:item)*) => {
$crate::cfg_feature!("client", $($item)*);
cfg_feature!("client", $($item)*);
Copy link
Collaborator Author

@jsdw jsdw May 6, 2022

Choose a reason for hiding this comment

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

I wasn't sure without trying, but things seem to work fine without properly namespacing the macro!

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, here be dragons. I think there are situations when this will not work well, but can't remember what the full story was. $crate::macros::cfg_feature! should work though right?

};
}

macro_rules! cfg_server {
($($item:item)*) => {
$crate::cfg_feature!("server", $($item)*);
cfg_feature!("server", $($item)*);
};
}

macro_rules! cfg_http_helpers {
($($item:item)*) => {
$crate::cfg_feature!("http-helpers", $($item)*);
cfg_feature!("http-helpers", $($item)*);
};
}

Expand Down
1 change: 1 addition & 0 deletions jsonrpsee/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
//! - **`client-ws-transport`** - Enables `ws` transport with TLS.
//! - **`client-ws-transport-no-tls`** - Enables `ws` transport without TLS.

// Macros useful below, but not to be exposed outside of the crate.
#[macro_use]
mod macros;

Expand Down
17 changes: 8 additions & 9 deletions jsonrpsee/src/macros.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#[macro_export]
macro_rules! cfg_feature {
($feature:literal, $($item:item)*) => {
$(
Expand All @@ -20,31 +19,31 @@ macro_rules! cfg_client {

macro_rules! cfg_http_client {
($($item:item)*) => {
$crate::cfg_feature!("jsonrpsee-http-client", $($item)*);
cfg_feature!("jsonrpsee-http-client", $($item)*);
};
}

macro_rules! cfg_ws_client {
($($item:item)*) => {
$crate::cfg_feature!("jsonrpsee-ws-client", $($item)*);
cfg_feature!("jsonrpsee-ws-client", $($item)*);
};
}

macro_rules! cfg_wasm_client {
($($item:item)*) => {
$crate::cfg_feature!("jsonrpsee-wasm-client", $($item)*);
cfg_feature!("jsonrpsee-wasm-client", $($item)*);
};
}

macro_rules! cfg_async_client {
($($item:item)*) => {
$crate::cfg_feature!("async-client", $($item)*);
cfg_feature!("async-client", $($item)*);
};
}

macro_rules! cfg_client_transport {
($($item:item)*) => {
$crate::cfg_feature!("jsonrpsee-client-transport", $($item)*);
cfg_feature!("jsonrpsee-client-transport", $($item)*);
};
}

Expand All @@ -69,19 +68,19 @@ macro_rules! cfg_http_server {

macro_rules! cfg_ws_server {
($($item:item)*) => {
$crate::cfg_feature!("jsonrpsee-ws-server", $($item)*);
cfg_feature!("jsonrpsee-ws-server", $($item)*);
};
}

macro_rules! cfg_proc_macros {
($($item:item)*) => {
$crate::cfg_feature!("jsonrpsee-proc-macros", $($item)*);
cfg_feature!("jsonrpsee-proc-macros", $($item)*);
};
}

macro_rules! cfg_types {
($($item:item)*) => {
$crate::cfg_feature!("jsonrpsee-types", $($item)*);
cfg_feature!("jsonrpsee-types", $($item)*);
};
}

Expand Down