Debian Codegraph @

crt/s2n/bindings/rust/extended/s2n-tls/src/utilities.rs

raw symbols SCIP
1 // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 // SPDX-License-Identifier: Apache-2.0
3
4 use std::ffi::{c_char, CStr};
5
6 /// # Safety
7 ///
8 /// The caller must ensure the char pointer must contain a valid
9 /// UTF-8 string from a trusted source
10 pub(crate) unsafe fn cstr_to_str(v: *const c_char) -> &'static str {
11 let slice = CStr::from_ptr(v);
12 let bytes = slice.to_bytes();
13 core::str::from_utf8_unchecked(bytes)
14 }