pgx_pg_sys/submodules/
utils.rs

1/*
2Portions Copyright 2019-2021 ZomboDB, LLC.
3Portions Copyright 2021-2022 Technology Concepts & Design, Inc. <support@tcdi.com>
4
5All rights reserved.
6
7Use of this source code is governed by the MIT license that can be found in the LICENSE file.
8*/
9
10//! General utility functions
11use crate as pg_sys;
12
13/// Converts a `pg_sys::NameData` struct into a `&str`.  
14///
15/// This is a zero-copy operation and the returned `&str` is tied to the lifetime
16/// of the provided `pg_sys::NameData`
17#[inline]
18pub fn name_data_to_str(name_data: &pg_sys::NameData) -> &str {
19    unsafe { core::ffi::CStr::from_ptr(name_data.data.as_ptr()) }.to_str().unwrap()
20}