pgrx_sql_entity_graph/pg_extern/entity/
argument.rs

1//LICENSE Portions Copyright 2019-2021 ZomboDB, LLC.
2//LICENSE
3//LICENSE Portions Copyright 2021-2023 Technology Concepts & Design, Inc.
4//LICENSE
5//LICENSE Portions Copyright 2023-2023 PgCentral Foundation, Inc. <contact@pgcentral.org>
6//LICENSE
7//LICENSE All rights reserved.
8//LICENSE
9//LICENSE Use of this source code is governed by the MIT license that can be found in the LICENSE file.
10/*!
11
12`#[pg_extern]` related argument entities for Rust to SQL translation
13
14> Like all of the [`sql_entity_graph`][crate] APIs, this is considered **internal**
15> to the `pgrx` framework and very subject to change between versions. While you may use this, please do it with caution.
16
17*/
18use crate::{SqlGraphIdentifier, UsedTypeEntity};
19
20/// The output of a [`PgExternArgument`](crate::PgExternArgument) from `quote::ToTokens::to_tokens`.
21#[derive(Debug, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)]
22pub struct PgExternArgumentEntity {
23    pub pattern: &'static str,
24    pub used_ty: UsedTypeEntity,
25}
26
27impl SqlGraphIdentifier for PgExternArgumentEntity {
28    fn dot_identifier(&self) -> String {
29        format!("arg {}", self.rust_identifier())
30    }
31    fn rust_identifier(&self) -> String {
32        self.used_ty.full_path.to_string()
33    }
34
35    fn file(&self) -> Option<&'static str> {
36        None
37    }
38
39    fn line(&self) -> Option<u32> {
40        None
41    }
42}