pub enum ParameterAny<'a> {
None,
ValueInput(ParameterValueInput),
ValueInout(ParameterValueInout<'a>),
ValueOutput(ParameterValueOutput<'a>),
MemrefInput(ParameterMemrefInput<'a>),
MemrefInout(ParameterMemrefInout<'a>),
MemrefOutput(ParameterMemrefOutput<'a>),
Unknown(RawParamType, &'a mut TEE_Param),
}Expand description
A type-erased parameter that dispatches to the correct concrete wrapper based on the runtime type tag.
§When to use
Use ParameterAny when the parameter type is not known at compile time
and must be determined at runtime. Typical scenarios:
- The command semantics allow multiple parameter types for the same slot
(e.g. “slot 0 may be
NoneorMemrefInputdepending on the command”). - A library helper is designed to inspect parameters generically without fixing the types in its signature.
If you already know the expected type for a slot, prefer the concrete
wrappers from [value] and [memref] instead—they provide methods
specific to that type and avoid the match ceremony.
§Example
ⓘ
use optee_utee::parameter::{ParameterAny, FromRawParameter};
match param {
ParameterAny::None => { /* no parameter */ }
ParameterAny::MemrefInput(p) => {
let data: alloc::vec::Vec<u8> = p.read_to_vec();
// validate and use the TA-owned `data` ...
}
ParameterAny::ValueInput(p) => {
let a = p.get_a();
let b = p.get_b();
// use a, b ...
}
_ => return Err(ErrorKind::BadParameters.into()),
}Variants§
None
ValueInput(ParameterValueInput)
ValueInout(ParameterValueInout<'a>)
ValueOutput(ParameterValueOutput<'a>)
MemrefInput(ParameterMemrefInput<'a>)
MemrefInout(ParameterMemrefInout<'a>)
MemrefOutput(ParameterMemrefOutput<'a>)
Unknown(RawParamType, &'a mut TEE_Param)
Unrecognized or implementation-defined type tag.
Carries the raw RawParamType and a mutable reference to the
underlying TEE_Param so that the caller can handle it manually.
Implementations§
Source§impl<'a> ParameterAny<'a>
impl<'a> ParameterAny<'a>
pub fn as_value_input(&self) -> Result<&ParameterValueInput>
pub fn as_value_output(&mut self) -> Result<&mut ParameterValueOutput<'a>>
pub fn as_value_inout(&mut self) -> Result<&mut ParameterValueInout<'a>>
pub fn as_memref_input(&self) -> Result<&ParameterMemrefInput<'a>>
pub fn as_memref_inout(&mut self) -> Result<&mut ParameterMemrefInout<'a>>
pub fn as_memref_output(&mut self) -> Result<&mut ParameterMemrefOutput<'a>>
pub fn as_none(&self) -> Result<()>
Trait Implementations§
Source§impl<'a> FromRawParameter<'a> for ParameterAny<'a>
impl<'a> FromRawParameter<'a> for ParameterAny<'a>
Auto Trait Implementations§
impl<'a> !Send for ParameterAny<'a>
impl<'a> !Sync for ParameterAny<'a>
impl<'a> !UnwindSafe for ParameterAny<'a>
impl<'a> Freeze for ParameterAny<'a>
impl<'a> RefUnwindSafe for ParameterAny<'a>
impl<'a> Unpin for ParameterAny<'a>
impl<'a> UnsafeUnpin for ParameterAny<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more