pub struct Internal(/* private fields */);
Expand description
Represents Postgres’ internal
data type, which is documented as:
The internal pseudo-type is used to declare functions that are meant only to be called internally by the database system, and not by direct invocation in an SQL query. If a function has at least one internal-type argument then it cannot be called from SQL. To preserve the type safety of this restriction it is important to follow this coding rule: do not create any function that is declared to return internal unless it has at least one internal argument.
§Implementation Notes
Internal is a wrapper around an Option<pg_sys::Datum>
, which when retrieved via
::get/get_mut()
is cast to a pointer of T
, returning the respective reference.
§Safety
We make no guarantees about what the internal pg_sys::Datum actually points to in memory, so it is your responsibility to ensure that what you’re casting it to is really what it is.
Implementations§
Source§impl Internal
impl Internal
Sourcepub fn new<T>(t: T) -> Self
pub fn new<T>(t: T) -> Self
Construct a new Internal from any type.
The value will be dropped when the PgMemoryContexts::CurrentMemoryContext is deleted.
Sourcepub fn initialized(&self) -> bool
pub fn initialized(&self) -> bool
Returns true if the internal value is initialized. If false, this is a null pointer.
Sourcepub unsafe fn insert<T>(&mut self, value: T) -> &mut T
pub unsafe fn insert<T>(&mut self, value: T) -> &mut T
Initializes the internal with value
, then returns a mutable reference to it.
If the Internal is already initialized with a value, the old value is dropped.
See also Internal::get_or_insert
, which doesn’t update the value if already initialized.
§Safety
We cannot guarantee that the contained datum points to memory that is really T
. This is
your responsibility.
Sourcepub unsafe fn get_or_insert<T>(&mut self, value: T) -> &mut T
pub unsafe fn get_or_insert<T>(&mut self, value: T) -> &mut T
Initializes the internal with value
if it is not initialized, then returns a mutable reference to
the contained value.
See also Internal::insert
, which updates the value even if the option already contains Some.
§Safety
We cannot guarantee that the contained datum points to memory that is really T
. This is
your responsibility.
Sourcepub unsafe fn get_or_insert_default<T>(&mut self) -> &mut Twhere
T: Default,
pub unsafe fn get_or_insert_default<T>(&mut self) -> &mut Twhere
T: Default,
Initializes the internal with a default if it is not initialized, then returns a mutable reference to the contained value.
See also Internal::insert
, which updates the value even if the option already contains Some.
§Safety
We cannot guarantee that the contained datum points to memory that is really T
. This is
your responsibility.
Sourcepub unsafe fn get_or_insert_with<F, T>(&mut self, f: F) -> &mut Twhere
F: FnOnce() -> T,
pub unsafe fn get_or_insert_with<F, T>(&mut self, f: F) -> &mut Twhere
F: FnOnce() -> T,
Inserts a value computed from f
into the internal if it is None
, then returns a mutable reference
to the contained value.
§Safety
We cannot guarantee that the contained datum points to memory that is really T
. This is
your responsibility.
Trait Implementations§
Source§impl<'fcx> ArgAbi<'fcx> for Internal
impl<'fcx> ArgAbi<'fcx> for Internal
Source§unsafe fn unbox_arg_unchecked(arg: Arg<'_, 'fcx>) -> Self
unsafe fn unbox_arg_unchecked(arg: Arg<'_, 'fcx>) -> Self
Source§unsafe fn unbox_nullable_arg(arg: Arg<'_, 'fcx>) -> Nullable<Self>
unsafe fn unbox_nullable_arg(arg: Arg<'_, 'fcx>) -> Nullable<Self>
Source§fn is_virtual_arg() -> bool
fn is_virtual_arg() -> bool
Source§impl FromDatum for Internal
impl FromDatum for Internal
Source§unsafe fn from_polymorphic_datum(
datum: Datum,
is_null: bool,
_: Oid,
) -> Option<Internal>
unsafe fn from_polymorphic_datum( datum: Datum, is_null: bool, _: Oid, ) -> Option<Internal>
from_datum
for instantiating polymorphic types
which require preserving the dynamic type metadata. Read moreSource§const GET_TYPOID: bool = false
const GET_TYPOID: bool = false
from_datum
?Source§unsafe fn from_datum_in_memory_context(
memory_context: PgMemoryContexts,
datum: Datum,
is_null: bool,
typoid: Oid,
) -> Option<Self>
unsafe fn from_datum_in_memory_context( memory_context: PgMemoryContexts, datum: Datum, is_null: bool, typoid: Oid, ) -> Option<Self>
FromDatum::from_datum(...)
from within that context. Read moreSource§unsafe fn try_from_datum(
datum: Datum,
is_null: bool,
type_oid: Oid,
) -> Result<Option<Self>, TryFromDatumError>where
Self: IntoDatum,
unsafe fn try_from_datum(
datum: Datum,
is_null: bool,
type_oid: Oid,
) -> Result<Option<Self>, TryFromDatumError>where
Self: IntoDatum,
try_from_datum
is a convenience wrapper around FromDatum::from_datum
that returns a
a Result
around an Option
, as a Datum can be null. It’s intended to be used in
situations where the caller needs to know whether the type conversion succeeded or failed. Read moreSource§unsafe fn try_from_datum_in_memory_context(
memory_context: PgMemoryContexts,
datum: Datum,
is_null: bool,
type_oid: Oid,
) -> Result<Option<Self>, TryFromDatumError>where
Self: IntoDatum,
unsafe fn try_from_datum_in_memory_context(
memory_context: PgMemoryContexts,
datum: Datum,
is_null: bool,
type_oid: Oid,
) -> Result<Option<Self>, TryFromDatumError>where
Self: IntoDatum,
try_from_datum
that switches to the given context to convert from DatumSource§impl SqlTranslatable for Internal
impl SqlTranslatable for Internal
fn argument_sql() -> Result<SqlMapping, ArgumentError>
fn return_sql() -> Result<Returns, ReturnsError>
fn optional() -> bool
fn type_name() -> &'static str
fn variadic() -> bool
fn entity() -> FunctionMetadataTypeEntity
Auto Trait Implementations§
impl Freeze for Internal
impl RefUnwindSafe for Internal
impl !Send for Internal
impl !Sync for Internal
impl Unpin for Internal
impl UnwindSafe for Internal
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.