Skip to main content

SqlTranslatable

Trait SqlTranslatable 

Source
pub unsafe trait SqlTranslatable {
    const TYPE_IDENT: &'static str;
    const TYPE_ORIGIN: TypeOrigin;
    const ARGUMENT_SQL: Result<SqlMappingRef, ArgumentError>;
    const RETURN_SQL: Result<ReturnsRef, ReturnsError>;

    // Provided methods
    fn type_name() -> &'static str { ... }
    fn argument_sql() -> Result<SqlMapping, ArgumentError> { ... }
    fn return_sql() -> Result<Returns, ReturnsError> { ... }
    fn entity() -> FunctionMetadataTypeEntity<'static> { ... }
}
Expand description

A value which can be represented in SQL

If you need the common “fixed external SQL type” case, prefer impl_sql_translatable!. Spell out this trait impl when (1) the type is owned by this extension or (2) when the argument or return SQL is unusual.

§Safety

By implementing this, you assert you are not lying to either Postgres or Rust in doing so. This trait asserts a safe translation exists between values of this type from Rust to SQL, or from SQL into Rust. If you are mistaken about how this works, either the Postgres C API or the Rust handling in PGRX may emit undefined behavior.

It cannot be made private or sealed due to details of the structure of the PGRX framework. Nonetheless, if you are not confident the translation is valid: do not implement this trait.

Required Associated Constants§

Provided Methods§

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl SqlTranslatable for bool

Source§

const TYPE_IDENT: &'static str = "pgrx_sql_entity_graph::metadata::sql_translatable::bool"

Source§

const TYPE_ORIGIN: TypeOrigin = TypeOrigin::External

Source§

const ARGUMENT_SQL: Result<SqlMappingRef, ArgumentError>

Source§

const RETURN_SQL: Result<ReturnsRef, ReturnsError>

Source§

impl SqlTranslatable for char

Source§

const TYPE_IDENT: &'static str = "pgrx_sql_entity_graph::metadata::sql_translatable::char"

Source§

const TYPE_ORIGIN: TypeOrigin = TypeOrigin::External

Source§

const ARGUMENT_SQL: Result<SqlMappingRef, ArgumentError>

Source§

const RETURN_SQL: Result<ReturnsRef, ReturnsError>

Source§

impl SqlTranslatable for f32

Source§

const TYPE_IDENT: &'static str = "pgrx_sql_entity_graph::metadata::sql_translatable::f32"

Source§

const TYPE_ORIGIN: TypeOrigin = TypeOrigin::External

Source§

const ARGUMENT_SQL: Result<SqlMappingRef, ArgumentError>

Source§

const RETURN_SQL: Result<ReturnsRef, ReturnsError>

Source§

impl SqlTranslatable for f64

Source§

const TYPE_IDENT: &'static str = "pgrx_sql_entity_graph::metadata::sql_translatable::f64"

Source§

const TYPE_ORIGIN: TypeOrigin = TypeOrigin::External

Source§

const ARGUMENT_SQL: Result<SqlMappingRef, ArgumentError>

Source§

const RETURN_SQL: Result<ReturnsRef, ReturnsError>

Source§

impl SqlTranslatable for i8

Source§

const TYPE_IDENT: &'static str = "pgrx_sql_entity_graph::metadata::sql_translatable::i8"

Source§

const TYPE_ORIGIN: TypeOrigin = TypeOrigin::External

Source§

const ARGUMENT_SQL: Result<SqlMappingRef, ArgumentError>

Source§

const RETURN_SQL: Result<ReturnsRef, ReturnsError>

Source§

impl SqlTranslatable for i16

Source§

const TYPE_IDENT: &'static str = "pgrx_sql_entity_graph::metadata::sql_translatable::i16"

Source§

const TYPE_ORIGIN: TypeOrigin = TypeOrigin::External

Source§

const ARGUMENT_SQL: Result<SqlMappingRef, ArgumentError>

Source§

const RETURN_SQL: Result<ReturnsRef, ReturnsError>

Source§

impl SqlTranslatable for i32

Source§

const TYPE_IDENT: &'static str = "pgrx_sql_entity_graph::metadata::sql_translatable::i32"

Source§

const TYPE_ORIGIN: TypeOrigin = TypeOrigin::External

Source§

const ARGUMENT_SQL: Result<SqlMappingRef, ArgumentError>

Source§

const RETURN_SQL: Result<ReturnsRef, ReturnsError>

Source§

impl SqlTranslatable for i64

Source§

const TYPE_IDENT: &'static str = "pgrx_sql_entity_graph::metadata::sql_translatable::i64"

Source§

const TYPE_ORIGIN: TypeOrigin = TypeOrigin::External

Source§

const ARGUMENT_SQL: Result<SqlMappingRef, ArgumentError>

Source§

const RETURN_SQL: Result<ReturnsRef, ReturnsError>

Source§

impl SqlTranslatable for str

Source§

const TYPE_IDENT: &'static str = "pgrx_sql_entity_graph::metadata::sql_translatable::str"

Source§

const TYPE_ORIGIN: TypeOrigin = TypeOrigin::External

Source§

const ARGUMENT_SQL: Result<SqlMappingRef, ArgumentError>

Source§

const RETURN_SQL: Result<ReturnsRef, ReturnsError>

Source§

impl SqlTranslatable for u8

Source§

const TYPE_IDENT: &'static str = "pgrx_sql_entity_graph::metadata::sql_translatable::u8"

Source§

const TYPE_ORIGIN: TypeOrigin = TypeOrigin::External

Source§

const ARGUMENT_SQL: Result<SqlMappingRef, ArgumentError>

Source§

const RETURN_SQL: Result<ReturnsRef, ReturnsError>

Source§

impl SqlTranslatable for ()

Source§

const TYPE_IDENT: &'static str = "pgrx_sql_entity_graph::metadata::sql_translatable::()"

Source§

const TYPE_ORIGIN: TypeOrigin = TypeOrigin::External

Source§

const ARGUMENT_SQL: Result<SqlMappingRef, ArgumentError>

Source§

const RETURN_SQL: Result<ReturnsRef, ReturnsError>

Source§

impl SqlTranslatable for CString

Source§

const TYPE_IDENT: &'static str = "pgrx_sql_entity_graph::metadata::sql_translatable::CString"

Source§

const TYPE_ORIGIN: TypeOrigin = TypeOrigin::External

Source§

const ARGUMENT_SQL: Result<SqlMappingRef, ArgumentError>

Source§

const RETURN_SQL: Result<ReturnsRef, ReturnsError>

Source§

impl SqlTranslatable for String

Source§

const TYPE_IDENT: &'static str = "pgrx_sql_entity_graph::metadata::sql_translatable::String"

Source§

const TYPE_ORIGIN: TypeOrigin = TypeOrigin::External

Source§

const ARGUMENT_SQL: Result<SqlMappingRef, ArgumentError>

Source§

const RETURN_SQL: Result<ReturnsRef, ReturnsError>

Source§

impl SqlTranslatable for CStr

Source§

const TYPE_IDENT: &'static str = "pgrx_sql_entity_graph::metadata::sql_translatable::CStr"

Source§

const TYPE_ORIGIN: TypeOrigin = TypeOrigin::External

Source§

const ARGUMENT_SQL: Result<SqlMappingRef, ArgumentError>

Source§

const RETURN_SQL: Result<ReturnsRef, ReturnsError>

Source§

impl SqlTranslatable for [u8]

Source§

const TYPE_IDENT: &'static str = "pgrx_sql_entity_graph::metadata::sql_translatable::[u8]"

Source§

const TYPE_ORIGIN: TypeOrigin = TypeOrigin::External

Source§

const ARGUMENT_SQL: Result<SqlMappingRef, ArgumentError>

Source§

const RETURN_SQL: Result<ReturnsRef, ReturnsError>

Source§

impl<T> SqlTranslatable for Option<T>
where T: SqlTranslatable,

Source§

const TYPE_IDENT: &'static str = T::TYPE_IDENT

Source§

const TYPE_ORIGIN: TypeOrigin = T::TYPE_ORIGIN

Source§

const ARGUMENT_SQL: Result<SqlMappingRef, ArgumentError> = T::ARGUMENT_SQL

Source§

const RETURN_SQL: Result<ReturnsRef, ReturnsError> = T::RETURN_SQL

Source§

impl<T> SqlTranslatable for *mut T
where T: SqlTranslatable,

Source§

const TYPE_IDENT: &'static str = T::TYPE_IDENT

Source§

const TYPE_ORIGIN: TypeOrigin = T::TYPE_ORIGIN

Source§

const ARGUMENT_SQL: Result<SqlMappingRef, ArgumentError> = T::ARGUMENT_SQL

Source§

const RETURN_SQL: Result<ReturnsRef, ReturnsError> = T::RETURN_SQL

Source§

impl<T> SqlTranslatable for &T
where T: ?Sized + SqlTranslatable,

Source§

const TYPE_IDENT: &'static str = T::TYPE_IDENT

Source§

const TYPE_ORIGIN: TypeOrigin = T::TYPE_ORIGIN

Source§

const ARGUMENT_SQL: Result<SqlMappingRef, ArgumentError> = T::ARGUMENT_SQL

Source§

const RETURN_SQL: Result<ReturnsRef, ReturnsError> = T::RETURN_SQL

Source§

impl<T> SqlTranslatable for Vec<T>
where T: SqlTranslatable,

Source§

impl<T, E> SqlTranslatable for Result<T, E>
where T: SqlTranslatable, E: Any + Display,

Source§

const TYPE_IDENT: &'static str = T::TYPE_IDENT

Source§

const TYPE_ORIGIN: TypeOrigin = T::TYPE_ORIGIN

Source§

const ARGUMENT_SQL: Result<SqlMappingRef, ArgumentError> = T::ARGUMENT_SQL

Source§

const RETURN_SQL: Result<ReturnsRef, ReturnsError> = T::RETURN_SQL

Implementors§