Struct optee_utee::time::Time

source ·
pub struct Time {
    pub seconds: u32,
    pub millis: u32,
}
Expand description

A millisecond resolution structure for saving the time.

Fields§

§seconds: u32

The field for the seconds.

§millis: u32

The field for the milliseconds within this second.

Implementations§

source§

impl Time

source

pub fn new() -> Self

Create a new empty time structure.

source

pub fn system_time(&mut self)

Retrieve the current system time. The origin of this system time is arbitrary and implementation-dependent. Different TA instances may even have different system times. The only guarantee is that the system time is not reset or rolled back during the life of a given TA instance, so it can be used to compute time differences and operation deadlines.

§Example
let mut time = Time::new();
time.system_time();
§Panics
  1. If the Implementation detects any error.
source

pub fn wait(timeout: u32) -> Result<()>

Wait for the specified number of milliseconds or wait forever if timeout equals raw::TEE_TIMEOUT_INFINITE (0xFFFFFFFF). The waiting timer is System Time.

§Parameters
  1. timeout: The number of milliseconds to wait, or raw::TEE_TIMEOUT_INFINITE.
§Example
Time::wait(1000)?;
§Errors
  1. Cancel: If the wait has been cancelled.
§Panics
  1. If the Implementation detects any error.
source

pub fn ta_time(&mut self) -> Result<()>

Retrieve the persisten time of the Trusted Application. Since the timer is not automatically set, this function should be called after set_ta_time. The time is a real-time source of time and the origin of this time is set individually by each Trusted Application. Also, the time SHALL persist across reboots.

§Example
let mut time = Time::new();
time.system_time();
time.set_ta_time()?;
time.ta_time()?;
§Errors
  1. TimeNotSet: Time is not set.
  2. TimeNeedsReset: Time needs to be reset.
  3. Overflow: The number of seconds in the TA Persistent Time overflows the range of a u32. The field seconds is still set to the TA Persistent Time truncated to 32 bits.
§Panics
  1. If the Implementation detects any error.
source

pub fn set_ta_time(&self) -> Result<()>

Set the persistent time of the current Trusted Application.

§Errors
  1. OutOfMemory: If not enough memory is available to complete the operation.
  2. SotrageNoSpace: If insufficient storage space is available to complete the operation.
§Panics
  1. If the Implementation detects any error.
source

pub fn ree_time(&mut self)

Retrieve the current REE system time. The time is as trusted as the REE itself and may also be tampered by the user.

Panics

  1. If the Implementation detects any error.

Trait Implementations§

source§

impl Display for Time

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Time

§

impl RefUnwindSafe for Time

§

impl Send for Time

§

impl Sync for Time

§

impl Unpin for Time

§

impl UnwindSafe for Time

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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>,

§

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.