pub fn tee_command(attr: TokenStream, item: TokenStream) -> TokenStreamExpand description
Generates two companion functions for a TA command handler.
function_name_dispatched (TA side, default, #[cfg(feature = "ta")]): unpacks ::optee_utee::Parameters via the
[TeeParam] trait, calls the original function, and flushes any output or inout values
back into their slots.
call_function_name (CA side, #[cfg(feature = "ca")]): packs arguments via
[TeeParam], calls invoke_command, then reads output slots back.
The original function body is emitted unchanged.
§Codec attribute
When any parameter or return type implements TeeParam<C> for a serialized codec, you
must specify the codec:
#[tee_command(codec = PostcardCodec, ctx)]
fn my_handler(ctx: &mut Context, config: MyConfig) -> Result<(), TeeError> { /* … */ }The codec C is passed as the type parameter to all TeeParam<C> calls. For
primitive types (integers, booleans) the codec is ignored — they always use the
TeeParamSlot::Primitive variant. Omitting codec uses ::consortium_tee::NoCodec
as the default, which causes a compile error if any serialized TeeParam types are
present (since NoCodec does not implement CodecFor<T>).
§Parameter type support
| Rust type | TEE slot | Notes |
|---|---|---|
&[u8] | MemrefInput | |
&mut [u8] | MemrefInout | |
&mut u32 | ValueInout | TA reads initial, writes result back |
&mut i32 | ValueInout | bit-cast through u32 |
&mut u64 | ValueInout | split across a(low)/b(high) |
T: TeeParam<C> | Value/Memref | dispatched via T::into_tee_param / from |
&mut T: TeeParam<C> | MemrefInout | inout codec round-trip |
ctx marks the first parameter as TA context. The parameter must be a mutable
reference to a named path type and is skipped when assigning TEE slots. ctx = name
and ctx = 0 are accepted for compatibility and emit a deprecation warning.
Return values use the same TeeParam<C> dispatch.