diff --git a/Cargo.toml b/Cargo.toml index 1f16391..175bbb5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "evident" -version = "0.7.0" +version = "0.8.0" edition = "2021" description = "Pub/Sub library using IDs to identify events." repository = "https://github.com/mhatzl/evident" diff --git a/src/creation_macros.rs b/src/creation_macros.rs index 517ebcc..fc1c707 100644 --- a/src/creation_macros.rs +++ b/src/creation_macros.rs @@ -8,13 +8,13 @@ /// ```ignore /// evident::create_static_publisher!( /// , -/// , -/// , -/// , +/// id_type = , +/// entry_type = , +/// interm_event_type = , /// filter_type = , /// filter = , -/// CAPTURE_CHANNEL_BOUND = <`usize` literal for the channel bound used to capture events>, -/// SUBSCRIPTION_CHANNEL_BOUND = <`usize` literal for the channel bound used per subscription>, +/// capture_channel_bound = <`usize` literal for the channel bound used to capture events>, +/// subscription_channel_bound = <`usize` literal for the channel bound used per subscription>, /// non_blocking = <`bool` literal defining if event finalizing should be non-blocking (`true`), or block the thread (`false`)> /// ); /// ``` @@ -24,11 +24,11 @@ /// ```ignore /// evident::create_static_publisher!( /// pub MY_PUBLISHER, -/// MyId, -/// MyEventEntry, -/// MyIntermEvent, -/// CAPTURE_CHANNEL_BOUND = 100, -/// SUBSCRIPTION_CHANNEL_BOUND = 50, +/// id_type = MyId, +/// entry_type = MyEventEntry, +/// interm_event_type = MyIntermEvent, +/// capture_channel_bound = 100, +/// subscription_channel_bound = 50, /// non_blocking = true /// ); /// ``` @@ -38,13 +38,13 @@ /// ```ignore /// evident::create_static_publisher!( /// pub MY_PUBLISHER, -/// MyId, -/// MyEventEntry, -/// MyIntermEvent, +/// id_type = MyId, +/// entry_type = MyEventEntry, +/// interm_event_type = MyIntermEvent, /// filter_type = MyFilter, /// filter = MyFilter::default(), -/// CAPTURE_CHANNEL_BOUND = 100, -/// SUBSCRIPTION_CHANNEL_BOUND = 50, +/// capture_channel_bound = 100, +/// subscription_channel_bound = 50, /// non_blocking = true /// ); /// ``` @@ -52,13 +52,13 @@ #[macro_export] macro_rules! create_static_publisher { ($publisher_name:ident, - $id_t:ty, - $entry_t:ty, - $interm_event_t:ty, + id_type = $id_t:ty, + entry_type = $entry_t:ty, + interm_event_type = $interm_event_t:ty, $(filter_type=$filter_t:ty,)? $(filter=$filter:expr,)? - CAPTURE_CHANNEL_BOUND = $cap_channel_bound:expr, - SUBSCRIPTION_CHANNEL_BOUND = $sub_channel_bound:expr, + capture_channel_bound = $cap_channel_bound:expr, + subscription_channel_bound = $sub_channel_bound:expr, non_blocking = $try_capture:literal ) => { $crate::z__setup_static_publisher!( @@ -74,13 +74,13 @@ macro_rules! create_static_publisher { ); }; ($visibility:vis $publisher_name:ident, - $id_t:ty, - $entry_t:ty, - $interm_event_t:ty, + id_type = $id_t:ty, + entry_type = $entry_t:ty, + interm_event_type = $interm_event_t:ty, $(filter_type=$filter_t:ty,)? $(filter=$filter:expr,)? - CAPTURE_CHANNEL_BOUND = $cap_channel_bound:expr, - SUBSCRIPTION_CHANNEL_BOUND = $sub_channel_bound:expr, + capture_channel_bound = $cap_channel_bound:expr, + subscription_channel_bound = $sub_channel_bound:expr, non_blocking = $try_capture:literal ) => { $crate::z__setup_static_publisher!( @@ -221,15 +221,15 @@ macro_rules! z__create_static_publisher { /// ## Usage /// /// In the following example, text between `<>` is used as placeholder. -/// `no_export` may be set at the beginning to prevent `#[macro_export]` from being added. +/// `no_export,` may be set at the beginning to prevent `#[macro_export]` from being added. /// -/// Note: Set fully qualified paths to make the macro accessible from anywhere. +/// Note: Set fully qualified paths for the types to make the macro accessible from anywhere. /// /// ```ignore /// evident::create_set_event_macro!( -/// , -/// , -/// +/// id_type = , +/// entry_type = , +/// interm_event_type = /// ); /// ``` /// @@ -237,17 +237,27 @@ macro_rules! z__create_static_publisher { /// /// ```ignore /// evident::create_set_event_macro!( -/// my_crate::my_mod::MyId, -/// my_crate::my_mod::MyEventEntry, -/// my_crate::my_mod::MyInterimEvent +/// id_type = my_crate::my_mod::MyId, +/// entry_type = my_crate::my_mod::MyEventEntry, +/// interm_event_type = my_crate::my_mod::MyInterimEvent +/// ); +/// ``` +/// +/// **Example with no export:** +/// +/// ```ignore +/// evident::create_set_event_macro!( +/// no_export, +/// id_type = my_crate::my_mod::MyId, +/// entry_type = my_crate::my_mod::MyEventEntry, +/// interm_event_type = my_crate::my_mod::MyInterimEvent /// ); /// ``` -/// #[macro_export] macro_rules! create_set_event_macro { - ($id_t:ty, - $entry_t:ty, - $interm_event_t:ty + (id_type = $id_t:ty, + entry_type = $entry_t:ty, + interm_event_type = $interm_event_t:ty ) => { #[macro_export] macro_rules! set_event { @@ -266,10 +276,10 @@ macro_rules! create_set_event_macro { }; } }; - (no_export - $id_t:ty, - $entry_t:ty, - $interm_event_t:ty + (no_export, + id_type = $id_t:ty, + entry_type = $entry_t:ty, + interm_event_type = $interm_event_t:ty ) => { macro_rules! set_event { ($id:expr) => { diff --git a/tests/min_concretise/mod.rs b/tests/min_concretise/mod.rs index d1fe272..dfd4125 100644 --- a/tests/min_concretise/mod.rs +++ b/tests/min_concretise/mod.rs @@ -6,20 +6,20 @@ mod interim_event; evident::create_static_publisher!( PUBLISHER, - MinId, - MinEventEntry, - MinInterimEvent, - CAPTURE_CHANNEL_BOUND = 1, - SUBSCRIPTION_CHANNEL_BOUND = 1, + id_type = MinId, + entry_type = MinEventEntry, + interm_event_type = MinInterimEvent, + capture_channel_bound = 1, + subscription_channel_bound = 1, non_blocking = true ); // Note: **no_export** to prevent the macro from adding `#[macro_export]`. evident::create_set_event_macro!( - no_export - MinId, - MinEventEntry, - MinInterimEvent + no_export, + id_type = MinId, + entry_type = MinEventEntry, + interm_event_type = MinInterimEvent ); #[test] diff --git a/tests/min_filter/mod.rs b/tests/min_filter/mod.rs index 359d670..5a7a4e3 100644 --- a/tests/min_filter/mod.rs +++ b/tests/min_filter/mod.rs @@ -7,22 +7,22 @@ mod interim_event; evident::create_static_publisher!( PUBLISHER, - MinId, - MinEventEntry, - MinInterimEvent, + id_type = MinId, + entry_type = MinEventEntry, + interm_event_type = MinInterimEvent, filter_type = MinFilter, filter = MinFilter::default(), - CAPTURE_CHANNEL_BOUND = 1, - SUBSCRIPTION_CHANNEL_BOUND = 1, + capture_channel_bound = 1, + subscription_channel_bound = 1, non_blocking = true ); // Note: **no_export** to prevent the macro from adding `#[macro_export]`. evident::create_set_event_macro!( - no_export - MinId, - MinEventEntry, - MinInterimEvent + no_export, + id_type = MinId, + entry_type = MinEventEntry, + interm_event_type = MinInterimEvent ); #[test] diff --git a/tests/pub_sub/setup/mod.rs b/tests/pub_sub/setup/mod.rs index 0a9c341..54116db 100644 --- a/tests/pub_sub/setup/mod.rs +++ b/tests/pub_sub/setup/mod.rs @@ -6,17 +6,17 @@ pub mod interim_event; evident::create_static_publisher!( pub TESTS_PUBLISHER, - MinId, - MinEventEntry, - MinInterimEvent, - CAPTURE_CHANNEL_BOUND = 500, - SUBSCRIPTION_CHANNEL_BOUND = 500, + id_type = MinId, + entry_type = MinEventEntry, + interm_event_type = MinInterimEvent, + capture_channel_bound = 500, + subscription_channel_bound = 500, non_blocking = true ); evident::create_set_event_macro!( - no_export - crate::pub_sub::setup::id::MinId, - crate::pub_sub::setup::entry::MinEventEntry, - crate::pub_sub::setup::interim_event::MinInterimEvent + no_export, + id_type = crate::pub_sub::setup::id::MinId, + entry_type = crate::pub_sub::setup::entry::MinEventEntry, + interm_event_type = crate::pub_sub::setup::interim_event::MinInterimEvent ); diff --git a/tests/public_concretise/public_publisher.rs b/tests/public_concretise/public_publisher.rs index cb01c09..ed78667 100644 --- a/tests/public_concretise/public_publisher.rs +++ b/tests/public_concretise/public_publisher.rs @@ -4,17 +4,17 @@ use crate::public_concretise::{entry::MinEventEntry, id::MinId, interim_event::M // Note: **non_blocking = false** will block on `finalize()` (or implicitly on `drop`) until publisher received the event. evident::create_static_publisher!( pub PUB_PUBLISHER, - MinId, - MinEventEntry, - MinInterimEvent, - CAPTURE_CHANNEL_BOUND = 1, - SUBSCRIPTION_CHANNEL_BOUND = 1, + id_type = MinId, + entry_type = MinEventEntry, + interm_event_type = MinInterimEvent, + capture_channel_bound = 1, + subscription_channel_bound = 1, non_blocking = false ); // Note: Fully qualified path to access the generated `set_event!()` macro from anywhere. evident::create_set_event_macro!( - crate::public_concretise::MinId, - crate::public_concretise::entry::MinEventEntry, - crate::public_concretise::interim_event::MinInterimEvent + id_type = crate::public_concretise::MinId, + entry_type = crate::public_concretise::entry::MinEventEntry, + interm_event_type = crate::public_concretise::interim_event::MinInterimEvent );