Skip to main content

ParameterAny

Enum ParameterAny 

Source
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 None or MemrefInput depending 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§

Trait Implementations§

Source§

impl<'a> FromRawParameter<'a> for ParameterAny<'a>

Source§

unsafe fn from_raw( raw_type: RawParamType, raw_param: &'a mut TEE_Param, ) -> Result<Self>

Construct Self from a raw parameter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.