diff options
| author | 1-rafael-1 <[email protected]> | 2025-09-15 20:07:18 +0200 |
|---|---|---|
| committer | 1-rafael-1 <[email protected]> | 2025-09-15 20:07:18 +0200 |
| commit | 6bb3d2c0720fa082f27d3cdb70f516058497ec87 (patch) | |
| tree | 5a1e255cff999b00800f203b91a759c720c973e5 /embassy-executor/src/lib.rs | |
| parent | eb685574601d98c44faed9a3534d056199b46e20 (diff) | |
| parent | 92a6fd2946f2cbb15359290f68aa360953da2ff7 (diff) | |
Merge branch 'main' into rp2040-rtc-alarm
Diffstat (limited to 'embassy-executor/src/lib.rs')
| -rw-r--r-- | embassy-executor/src/lib.rs | 56 |
1 files changed, 54 insertions, 2 deletions
diff --git a/embassy-executor/src/lib.rs b/embassy-executor/src/lib.rs index d6fd3d651..e47b8eb9f 100644 --- a/embassy-executor/src/lib.rs +++ b/embassy-executor/src/lib.rs | |||
| @@ -26,6 +26,7 @@ macro_rules! check_at_most_one { | |||
| 26 | check_at_most_one!( | 26 | check_at_most_one!( |
| 27 | "arch-avr", | 27 | "arch-avr", |
| 28 | "arch-cortex-m", | 28 | "arch-cortex-m", |
| 29 | "arch-cortex-ar", | ||
| 29 | "arch-riscv32", | 30 | "arch-riscv32", |
| 30 | "arch-std", | 31 | "arch-std", |
| 31 | "arch-wasm", | 32 | "arch-wasm", |
| @@ -35,6 +36,7 @@ check_at_most_one!( | |||
| 35 | #[cfg(feature = "_arch")] | 36 | #[cfg(feature = "_arch")] |
| 36 | #[cfg_attr(feature = "arch-avr", path = "arch/avr.rs")] | 37 | #[cfg_attr(feature = "arch-avr", path = "arch/avr.rs")] |
| 37 | #[cfg_attr(feature = "arch-cortex-m", path = "arch/cortex_m.rs")] | 38 | #[cfg_attr(feature = "arch-cortex-m", path = "arch/cortex_m.rs")] |
| 39 | #[cfg_attr(feature = "arch-cortex-ar", path = "arch/cortex_ar.rs")] | ||
| 38 | #[cfg_attr(feature = "arch-riscv32", path = "arch/riscv32.rs")] | 40 | #[cfg_attr(feature = "arch-riscv32", path = "arch/riscv32.rs")] |
| 39 | #[cfg_attr(feature = "arch-std", path = "arch/std.rs")] | 41 | #[cfg_attr(feature = "arch-std", path = "arch/std.rs")] |
| 40 | #[cfg_attr(feature = "arch-wasm", path = "arch/wasm.rs")] | 42 | #[cfg_attr(feature = "arch-wasm", path = "arch/wasm.rs")] |
| @@ -52,6 +54,9 @@ pub mod raw; | |||
| 52 | mod spawner; | 54 | mod spawner; |
| 53 | pub use spawner::*; | 55 | pub use spawner::*; |
| 54 | 56 | ||
| 57 | mod metadata; | ||
| 58 | pub use metadata::*; | ||
| 59 | |||
| 55 | /// Implementation details for embassy macros. | 60 | /// Implementation details for embassy macros. |
| 56 | /// Do not use. Used for macros and HALs only. Not covered by semver guarantees. | 61 | /// Do not use. Used for macros and HALs only. Not covered by semver guarantees. |
| 57 | #[doc(hidden)] | 62 | #[doc(hidden)] |
| @@ -63,8 +68,17 @@ pub mod _export { | |||
| 63 | 68 | ||
| 64 | use crate::raw::TaskPool; | 69 | use crate::raw::TaskPool; |
| 65 | 70 | ||
| 71 | trait TaskReturnValue {} | ||
| 72 | impl TaskReturnValue for () {} | ||
| 73 | impl TaskReturnValue for Never {} | ||
| 74 | |||
| 75 | #[diagnostic::on_unimplemented( | ||
| 76 | message = "task futures must resolve to `()` or `!`", | ||
| 77 | note = "use `async fn` or change the return type to `impl Future<Output = ()>`" | ||
| 78 | )] | ||
| 79 | #[allow(private_bounds)] | ||
| 66 | pub trait TaskFn<Args>: Copy { | 80 | pub trait TaskFn<Args>: Copy { |
| 67 | type Fut: Future + 'static; | 81 | type Fut: Future<Output: TaskReturnValue> + 'static; |
| 68 | } | 82 | } |
| 69 | 83 | ||
| 70 | macro_rules! task_fn_impl { | 84 | macro_rules! task_fn_impl { |
| @@ -72,7 +86,7 @@ pub mod _export { | |||
| 72 | impl<F, Fut, $($Tn,)*> TaskFn<($($Tn,)*)> for F | 86 | impl<F, Fut, $($Tn,)*> TaskFn<($($Tn,)*)> for F |
| 73 | where | 87 | where |
| 74 | F: Copy + FnOnce($($Tn,)*) -> Fut, | 88 | F: Copy + FnOnce($($Tn,)*) -> Fut, |
| 75 | Fut: Future + 'static, | 89 | Fut: Future<Output: TaskReturnValue> + 'static, |
| 76 | { | 90 | { |
| 77 | type Fut = Fut; | 91 | type Fut = Fut; |
| 78 | } | 92 | } |
| @@ -203,4 +217,42 @@ pub mod _export { | |||
| 203 | Align268435456: 268435456, | 217 | Align268435456: 268435456, |
| 204 | Align536870912: 536870912, | 218 | Align536870912: 536870912, |
| 205 | ); | 219 | ); |
| 220 | |||
| 221 | #[allow(dead_code)] | ||
| 222 | pub trait HasOutput { | ||
| 223 | type Output; | ||
| 224 | } | ||
| 225 | |||
| 226 | impl<O> HasOutput for fn() -> O { | ||
| 227 | type Output = O; | ||
| 228 | } | ||
| 229 | |||
| 230 | #[allow(dead_code)] | ||
| 231 | pub type Never = <fn() -> ! as HasOutput>::Output; | ||
| 232 | } | ||
| 233 | |||
| 234 | /// Implementation details for embassy macros. | ||
| 235 | /// Do not use. Used for macros and HALs only. Not covered by semver guarantees. | ||
| 236 | #[doc(hidden)] | ||
| 237 | #[cfg(feature = "nightly")] | ||
| 238 | pub mod _export { | ||
| 239 | #[diagnostic::on_unimplemented( | ||
| 240 | message = "task futures must resolve to `()` or `!`", | ||
| 241 | note = "use `async fn` or change the return type to `impl Future<Output = ()>`" | ||
| 242 | )] | ||
| 243 | pub trait TaskReturnValue {} | ||
| 244 | impl TaskReturnValue for () {} | ||
| 245 | impl TaskReturnValue for Never {} | ||
| 246 | |||
| 247 | #[allow(dead_code)] | ||
| 248 | pub trait HasOutput { | ||
| 249 | type Output; | ||
| 250 | } | ||
| 251 | |||
| 252 | impl<O> HasOutput for fn() -> O { | ||
| 253 | type Output = O; | ||
| 254 | } | ||
| 255 | |||
| 256 | #[allow(dead_code)] | ||
| 257 | pub type Never = <fn() -> ! as HasOutput>::Output; | ||
| 206 | } | 258 | } |
