1 /* 2 * Copyright (C) 2021 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 //! # The Trusty Rust Standard Library 18 //! 19 //! Rust for Trusty requires `no_std`, as the Rust standard library has not been 20 //! (and will likely never be) ported to Trusty. This crate provides a subset of 21 //! the standard library types and other generally useful APIs for building 22 //! trusted apps. 23 //! 24 //! This library is designed to accommodate fallible memory allocation and 25 //! provides types which may only be allocated fallibly. When the necessary APIs 26 //! are available [upstream](https://github.com/rust-lang/rust/issues/86942) or 27 //! in this crate, we plan to enable `no_global_oom_handling`, so do not write 28 //! code using this crate that relies on infallible allocation. 29 30 #![no_std] 31 #![allow(internal_features)] 32 #![feature(allocator_api)] 33 #![feature(alloc_error_handler)] 34 #![feature(alloc_layout_extra)] 35 #![feature(cfg_version)] 36 #![feature(core_intrinsics)] 37 // min_specialization is only used to optimize CString::try_new(), so we can 38 // remove it if needed 39 #![feature(min_specialization)] 40 #![feature(new_uninit)] 41 #![cfg_attr(not(version("1.81")), feature(panic_info_message))] 42 #![feature(slice_internals)] 43 #![feature(slice_ptr_get)] 44 45 // Import alloc with a different name to not clash with our local module 46 extern crate alloc as alloc_crate; 47 48 pub mod alloc; 49 mod clone_ext; 50 pub mod ffi; 51 52 pub use clone_ext::TryClone; 53 54 // Re-exports from core and alloc 55 pub use alloc_crate::{borrow, boxed, fmt, format, rc, slice, str, string, vec}; 56 57 pub use core::{ 58 any, arch, array, cell, char, clone, cmp, convert, default, future, hash, hint, i128, i16, i32, 59 i64, i8, intrinsics, isize, iter, marker, mem, ops, option, pin, primitive, ptr, result, u128, 60 u16, u32, u64, u8, usize, 61 }; 62 63 pub use core::{ 64 assert_eq, assert_ne, debug_assert, debug_assert_eq, debug_assert_ne, matches, todo, 65 unimplemented, unreachable, write, writeln, 66 }; 67 68 pub use core::{ 69 assert, cfg, column, compile_error, concat, env, file, format_args, include, include_bytes, 70 include_str, line, module_path, option_env, stringify, 71 }; 72