api_impl/
lib.rs

1// Copyright 2024 The Fuchsia Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5use tee_internal::Error;
6
7pub mod binding_stubs;
8pub mod context;
9pub mod crypto;
10pub mod mem;
11pub mod props;
12pub mod storage;
13pub mod time;
14
15/// Packages an error alongside an optional, context-dependent size. In
16/// particular, if `error` is `Error::ShortBuffer`, then `size`` is the
17/// required size of the output buffer for the operation in question.
18pub struct ErrorWithSize {
19    pub error: Error,
20    pub size: usize,
21}
22
23impl ErrorWithSize {
24    const fn new(error: Error) -> Self {
25        Self { error, size: 0 }
26    }
27
28    const fn short_buffer(size: usize) -> Self {
29        Self { error: Error::ShortBuffer, size }
30    }
31}
32
33pub fn panic(code: u32) {
34    std::process::exit(code as i32)
35}