taktora_executor/payload.rs
1//! Helper trait that bundles the payload-type bounds required by
2//! [`Channel<T>`](crate::Channel) and [`Service<Req, Resp>`](crate::Service).
3//!
4//! Users don't impl this trait themselves — there's a blanket impl for
5//! every `T` that satisfies the underlying iceoryx2 + taktora requirements.
6//! It exists purely so the compiler can show a clear error message when
7//! a user tries to use a type that's missing one of the required bounds.
8
9use iceoryx2::prelude::ZeroCopySend;
10
11/// Marker trait for types that can be carried over a [`Channel<T>`](crate::Channel)
12/// or [`Service<Req, Resp>`](crate::Service) — i.e., types that are
13/// `ZeroCopySend + Debug + 'static`.
14///
15/// `Default` is **not** required by the trait; it is only needed by
16/// [`Publisher::loan_send`](crate::Publisher::loan_send), which initialises the
17/// shared-memory slot via `T::default()` before handing it to the caller's
18/// closure. If your type does not implement `Default`, use
19/// [`Publisher::loan`](crate::Publisher::loan) instead.
20#[diagnostic::on_unimplemented(
21 note = "`{Self}` must derive `ZeroCopySend` and `Debug`.",
22 note = "Add `#[derive(Debug, ZeroCopySend)] #[repr(C)]` and the trait will be implemented automatically."
23)]
24pub trait Payload: ZeroCopySend + core::fmt::Debug + 'static {}
25
26impl<T> Payload for T where T: ZeroCopySend + core::fmt::Debug + 'static {}