Skip to content

Commit

Permalink
Update for v0.9 release (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmunns authored Oct 27, 2024
1 parent 5d0ab79 commit 0544018
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 16 deletions.
2 changes: 1 addition & 1 deletion example/firmware/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion example/firmware/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ embassy-usb = { version = "0.3.0", features = ["defmt"] }
embedded-hal-bus = { version = "0.1", features = ["async"] }
lis3dh-async = { version = "0.9.2", features = ["defmt"] }
panic-probe = { version = "0.3", features = ["print-defmt"] }
postcard-rpc = { version = "0.8", features = ["embassy-usb-0_3-server"] }
postcard-rpc = { version = "0.9", features = ["embassy-usb-0_3-server"] }
postcard = { version = "1.0.8" }
postcard-schema = { version = "0.1.0", features = ["derive"] }
portable-atomic = { version = "1.6.0", features = ["critical-section"] }
Expand Down
2 changes: 1 addition & 1 deletion example/workbook-host/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion example/workbook-host/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"
path = "../workbook-icd"

[dependencies.postcard-rpc]
version = "0.8"
version = "0.9"
features = [
"use-std",
"raw-nusb",
Expand Down
2 changes: 1 addition & 1 deletion example/workbook-icd/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion example/workbook-icd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ features = ["derive"]
default-features = false

[dependencies.postcard-rpc]
version = "0.8"
version = "0.9"

[dependencies.postcard-schema]
version = "0.1"
Expand Down
2 changes: 1 addition & 1 deletion source/postcard-rpc-test/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion source/postcard-rpc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "postcard-rpc"
version = "0.8.0"
version = "0.9.0"
authors = ["James Munns <[email protected]>"]
edition = "2021"
repository = "https://github.com/jamesmunns/postcard-rpc"
Expand Down
4 changes: 2 additions & 2 deletions source/postcard-rpc/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/// Used to define a single Endpoint marker type that implements the
/// [Endpoint][crate::Endpoint] trait.
///
/// Prefer the [`endpoints!()`][crate::endpoints]` macro instead.
/// Prefer the [`endpoints!()`][crate::endpoints] macro instead.
///
/// ```rust
/// # use postcard_schema::Schema;
Expand Down Expand Up @@ -135,7 +135,7 @@ macro_rules! endpoints {
/// Used to define a single Topic marker type that implements the
/// [Topic][crate::Topic] trait.
///
/// Prefer the [`topics!()` macro](crate::topics) macro.
/// Prefer the [`topics!()` macro](crate::topics) macro instead.
///
/// ```rust
/// # use postcard_schema::Schema;
Expand Down
62 changes: 56 additions & 6 deletions source/postcard-rpc/src/server/dispatch_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,56 @@ pub mod export {
}

/// Define Dispatch Macro
///
/// # Example
///
/// ```rust,ignore
/// use postcard_rpc::define_dispatch;
/// use postcard_rpc::server::impls::test_channels::dispatch_impl::*;
///
/// // This creates a type that implements the `Dispatcher` trait
/// define_dispatch! {
/// // This becomes the name of your dispatcher
/// app: SingleDispatcher;
/// // This is the spawn function, usually found in the `dispatch_impl` module of your
/// // implementation
/// spawn_fn: spawn_fn;
/// // This is the WireTx impl
/// tx_impl: WireTxImpl;
/// // This is the WireSpawn impl
/// spawn_impl: WireSpawnImpl;
/// // This is the TestContext you define to be passed to all handlers
/// context: TestContext;
///
/// endpoints: {
/// // This is the list you get from the `endpoints()` macro
/// list: ENDPOINT_LIST;
///
/// // These are all of your endpoints and the handlers they map to
/// | EndpointTy | kind | handler |
/// | ---------- | ---- | ------- |
/// | AlphaEndpoint | async | test_alpha_handler |
/// | BetaEndpoint | spawn | test_beta_handler |
/// };
/// topics_in: {
/// // This is the list you get from the `topics!()` macro
/// list: TOPICS_IN_LIST;
///
/// // These are the incoming topics and the handlers they map to
/// | TopicTy | kind | handler |
/// | ---------- | ---- | ------- |
/// | ZetaTopic1 | blocking | test_zeta_blocking |
/// | ZetaTopic2 | async | test_zeta_async |
/// | ZetaTopic3 | spawn | test_zeta_spawn |
/// };
/// topics_out: {
/// // This is the list you get from the `topics!()` macro
/// list: TOPICS_OUT_LIST;
///
/// // NOTE: outgoing topics don't have any handlers!
/// };
/// }
/// ```
#[macro_export]
macro_rules! define_dispatch {
//////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -119,7 +169,7 @@ macro_rules! define_dispatch {
let spawninfo = &dispatch.spawn;

// This will expand to the right "flavor" of handler
define_dispatch!(@ep_arm $ep_flavor ($endpoint) $ep_handler context hdr req tx ($spawn_fn) spawninfo)
$crate::define_dispatch!(@ep_arm $ep_flavor ($endpoint) $ep_handler context hdr req tx ($spawn_fn) spawninfo)
}
)*
$(
Expand All @@ -140,7 +190,7 @@ macro_rules! define_dispatch {
let spawninfo = &dispatch.spawn;

// (@tp_arm async $handler:ident $context:ident $header:ident $req:ident $outputter:ident)
define_dispatch!(@tp_arm $tp_flavor $tp_handler context hdr msg tx ($spawn_fn) spawninfo);
$crate::define_dispatch!(@tp_arm $tp_flavor $tp_handler context hdr msg tx ($spawn_fn) spawninfo);
Ok(())
}
)*
Expand Down Expand Up @@ -428,22 +478,22 @@ macro_rules! define_dispatch {
}
}

define_dispatch! {
$crate::define_dispatch! {
@matcher 1 $app_name $tx_impl; $spawn_fn $crate::Key1; $crate::header::VarKeyKind::Key1;
($($endpoint | $ep_flavor | $ep_handler)*)
($($topic_in | $tp_flavor | $tp_handler)*)
}
define_dispatch! {
$crate::define_dispatch! {
@matcher 2 $app_name $tx_impl; $spawn_fn $crate::Key2; $crate::header::VarKeyKind::Key2;
($($endpoint | $ep_flavor | $ep_handler)*)
($($topic_in | $tp_flavor | $tp_handler)*)
}
define_dispatch! {
$crate::define_dispatch! {
@matcher 4 $app_name $tx_impl; $spawn_fn $crate::Key4; $crate::header::VarKeyKind::Key4;
($($endpoint | $ep_flavor | $ep_handler)*)
($($topic_in | $tp_flavor | $tp_handler)*)
}
define_dispatch! {
$crate::define_dispatch! {
@matcher 8 $app_name $tx_impl; $spawn_fn $crate::Key; $crate::header::VarKeyKind::Key8;
($($endpoint | $ep_flavor | $ep_handler)*)
($($topic_in | $tp_flavor | $tp_handler)*)
Expand Down

0 comments on commit 0544018

Please sign in to comment.