Skip to main content

FunctionBuilder

Struct FunctionBuilder 

Source
pub struct FunctionBuilder { /* private fields */ }
Expand description

Builder for constructing database functions

Implementations§

Source§

impl FunctionBuilder

Source

pub fn new() -> Self

Create a new function builder

Source

pub fn name(self, name: impl Into<String>) -> Self

Set the function name (can be schema-qualified like “auth.my_function”)

Source

pub fn set_name(&mut self, name: impl Into<String>)

Set the function name (mutable reference version for conditional building) Can be schema-qualified like “auth.my_function”

Source

pub fn in_schema(self, schema: impl Into<String>) -> Self

Set the schema name

Source

pub fn set_schema(&mut self, schema: impl Into<String>)

Set the schema name (mutable reference version for conditional building)

Source

pub fn parameter( self, name: impl Into<String>, param_type: impl Into<String>, ) -> Self

Add a parameter to the function

Source

pub fn add_parameter( &mut self, name: impl Into<String>, param_type: impl Into<String>, )

Add a parameter to the function (mutable reference version for conditional building)

Source

pub fn parameters( self, params: impl IntoIterator<Item = (impl Into<String>, impl Into<String>)>, ) -> Self

Add multiple parameters to the function

Source

pub fn add_parameters( &mut self, params: impl IntoIterator<Item = (impl Into<String>, impl Into<String>)>, )

Add multiple parameters to the function (mutable reference version for conditional building)

Source

pub fn returns(self, return_type: impl Into<String>) -> Self

Set the return type

Source

pub fn set_return_type(&mut self, return_type: impl Into<String>)

Set the return type (mutable reference version for conditional building)

Source

pub fn language(self, language: ProcedureLanguage) -> Self

Set the function language

Source

pub fn set_language(&mut self, language: ProcedureLanguage)

Set the function language (mutable reference version for conditional building)

Source

pub fn volatility(self, volatility: FunctionVolatility) -> Self

Set the function volatility

Source

pub fn set_volatility(&mut self, volatility: FunctionVolatility)

Set the function volatility (mutable reference version for conditional building)

Source

pub fn security(self, security: FunctionSecurity) -> Self

Set the function security

Source

pub fn set_security(&mut self, security: FunctionSecurity)

Set the function security (mutable reference version for conditional building)

Source

pub fn body(self, body: impl Into<String>) -> Self

Set the function body

Source

pub fn set_body(&mut self, body: impl Into<String>)

Set the function body (mutable reference version for conditional building)

Source

pub fn comment(self, comment: impl Into<String>) -> Self

Set a comment on the function

Source

pub fn set_comment(&mut self, comment: impl Into<String>)

Set a comment on the function (mutable reference version for conditional building)

Source

pub fn simple() -> Self

Create a simple function

Source

pub fn plpgsql() -> Self

Create a PL/pgSQL function

Source

pub fn sql() -> Self

Create a SQL function

Source

pub fn c() -> Self

Create a C function

Source

pub fn immutable() -> Self

Create an immutable function

Source

pub fn stable() -> Self

Create a stable function

Source

pub fn volatile() -> Self

Create a volatile function

Source

pub fn invoker() -> Self

Create a function with invoker security

Source

pub fn definer() -> Self

Create a function with definer security

Source

pub fn math() -> Self

Create a math function

Source

pub fn utility() -> Self

Create a utility function

Source

pub fn trigger() -> Self

Create a trigger function

Source

pub fn get_name(&self) -> Option<&str>

Get the function name

Source

pub fn get_schema(&self) -> Option<&str>

Get the schema name

Source

pub fn get_parameters(&self) -> &[ProcedureParameter]

Get the parameters in the function

Source

pub fn get_return_type(&self) -> Option<&str>

Get the return type

Source

pub fn get_language(&self) -> Option<&ProcedureLanguage>

Get the function language

Source

pub fn get_volatility(&self) -> Option<&FunctionVolatility>

Get the function volatility

Source

pub fn get_security(&self) -> Option<&FunctionSecurity>

Get the function security

Source

pub fn get_body(&self) -> Option<&str>

Get the function body

Source

pub fn get_comment(&self) -> Option<&str>

Get the comment

Source

pub fn parameter_count(&self) -> usize

Get the number of parameters in the function

Source

pub fn has_parameter(&self, param_name: &str) -> bool

Check if the function has a specific parameter

Source

pub fn get_parameter(&self, param_name: &str) -> Option<&ProcedureParameter>

Get a specific parameter by name

Source

pub fn has_name(&self) -> bool

Check if the function has a name

Source

pub fn has_schema(&self) -> bool

Check if the function has a schema

Source

pub fn has_return_type(&self) -> bool

Check if the function has a return type

Source

pub fn has_language(&self) -> bool

Check if the function has a language

Source

pub fn has_volatility(&self) -> bool

Check if the function has a volatility

Source

pub fn has_security(&self) -> bool

Check if the function has a security setting

Source

pub fn has_body(&self) -> bool

Check if the function has a body

Source

pub fn has_comment(&self) -> bool

Check if the function has a comment

Source

pub fn has_parameters(&self) -> bool

Check if the function has parameters

Trait Implementations§

Source§

impl Clone for FunctionBuilder

Source§

fn clone(&self) -> FunctionBuilder

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl ConditionalBuilder for FunctionBuilder

Source§

fn when<F>(self, condition: bool, config_fn: F) -> Self
where F: FnOnce(&mut Self), Self: Sized,

Apply configuration conditionally Read more
Source§

fn when_else<F, G>(self, condition: bool, if_true: F, if_false: G) -> Self
where F: FnOnce(&mut Self), G: FnOnce(&mut Self), Self: Sized,

Apply configuration conditionally with a default fallback Read more
Source§

impl Debug for FunctionBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl InspectableBuilder for FunctionBuilder

Source§

fn debug_info(&self) -> String

Get a debug representation of the current builder state Read more
Source§

fn summary(&self) -> String

Get a summary of the current configuration Read more
Source§

impl SchemaBuilder for FunctionBuilder

Source§

type Output = StoredFunction

The type of schema object that this builder produces
Source§

type Error = FunctionBuildError

The type of error that can occur during building
Source§

fn build(self) -> Result<Self::Output, Self::Error>

Build the final schema object from the builder configuration Read more
Source§

impl ValidatableBuilder for FunctionBuilder

Source§

fn is_valid(&self) -> bool

Check if the current builder configuration is valid Read more
Source§

fn validation_errors(&self) -> Vec<String>

Get a list of validation errors for the current configuration Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more