Skip to main content

std/os/fortanix_sgx/
ffi.rs

1//! SGX-specific extension to the primitives in the `std::ffi` module
2//!
3//! # Examples
4//!
5#![cfg_attr(all(target_vendor = "fortanix", target_env = "sgx"), doc = "```")]
6#![cfg_attr(
7    not(all(target_vendor = "fortanix", target_env = "sgx")),
8    doc = "```ignore (needs aix)"
9)]
10//! use std::ffi::OsString;
11//! use std::os::fortanix_sgx::ffi::OsStringExt;
12//!
13//! let bytes = b"foo".to_vec();
14//!
15//! // OsStringExt::from_vec
16//! let os_string = OsString::from_vec(bytes);
17//! assert_eq!(os_string.to_str(), Some("foo"));
18//!
19//! // OsStringExt::into_vec
20//! let bytes = os_string.into_vec();
21//! assert_eq!(bytes, b"foo");
22//! ```
23//!
24#![cfg_attr(all(target_vendor = "fortanix", target_env = "sgx"), doc = "```")]
25#![cfg_attr(
26    not(all(target_vendor = "fortanix", target_env = "sgx")),
27    doc = "```ignore (needs aix)"
28)]
29//! use std::ffi::OsStr;
30//! use std::os::fortanix_sgx::ffi::OsStrExt;
31//!
32//! let bytes = b"foo";
33//!
34//! // OsStrExt::from_bytes
35//! let os_str = OsStr::from_bytes(bytes);
36//! assert_eq!(os_str.to_str(), Some("foo"));
37//!
38//! // OsStrExt::as_bytes
39//! let bytes = os_str.as_bytes();
40//! assert_eq!(bytes, b"foo");
41//! ```
42
43#![unstable(feature = "sgx_platform", issue = "56975")]
44
45#[path = "../unix/ffi/os_str.rs"]
46mod os_str;
47
48#[unstable(feature = "sgx_platform", issue = "56975")]
49pub use self::os_str::{OsStrExt, OsStringExt};