pub struct FunctionDef { /* private fields */ }Expand description
Function definition for CREATE FUNCTION
This struct represents a function definition, including its name, parameters, return type, language, behavior, security, and body.
§Examples
use reinhardt_query::types::function::{FunctionDef, FunctionLanguage};
// CREATE FUNCTION my_func() RETURNS integer
let func = FunctionDef::new("my_func")
.returns("integer")
.language(FunctionLanguage::Sql)
.body("SELECT 1");Implementations§
Source§impl FunctionDef
impl FunctionDef
Sourcepub fn new<N: IntoIden>(name: N) -> Self
pub fn new<N: IntoIden>(name: N) -> Self
Create a new function definition
§Examples
use reinhardt_query::types::function::FunctionDef;
let func = FunctionDef::new("my_func");Sourcepub fn or_replace(self, or_replace: bool) -> Self
pub fn or_replace(self, or_replace: bool) -> Self
Set OR REPLACE clause
§Examples
use reinhardt_query::types::function::FunctionDef;
let func = FunctionDef::new("my_func")
.or_replace(true);Sourcepub fn add_parameter<N: IntoIden, T: Into<String>>(
self,
name: N,
param_type: T,
) -> Self
pub fn add_parameter<N: IntoIden, T: Into<String>>( self, name: N, param_type: T, ) -> Self
Add a function parameter
§Examples
use reinhardt_query::types::function::FunctionDef;
let func = FunctionDef::new("my_func")
.add_parameter("param1", "integer")
.add_parameter("param2", "text");Sourcepub fn add_parameter_spec(self, param: FunctionParameter) -> Self
pub fn add_parameter_spec(self, param: FunctionParameter) -> Self
Add a function parameter with full specification
§Examples
use reinhardt_query::types::function::{FunctionDef, FunctionParameter, ParameterMode};
let param = FunctionParameter::new()
.name("my_param")
.param_type("integer")
.mode(ParameterMode::InOut);
let func = FunctionDef::new("my_func")
.add_parameter_spec(param);Sourcepub fn returns<T: Into<String>>(self, returns: T) -> Self
pub fn returns<T: Into<String>>(self, returns: T) -> Self
Set RETURNS type
§Examples
use reinhardt_query::types::function::FunctionDef;
let func = FunctionDef::new("my_func")
.returns("integer");Sourcepub fn language(self, language: FunctionLanguage) -> Self
pub fn language(self, language: FunctionLanguage) -> Self
Set LANGUAGE
§Examples
use reinhardt_query::types::function::{FunctionDef, FunctionLanguage};
let func = FunctionDef::new("my_func")
.language(FunctionLanguage::PlPgSql);Sourcepub fn behavior(self, behavior: FunctionBehavior) -> Self
pub fn behavior(self, behavior: FunctionBehavior) -> Self
Set function behavior (IMMUTABLE/STABLE/VOLATILE)
§Examples
use reinhardt_query::types::function::{FunctionDef, FunctionBehavior};
let func = FunctionDef::new("my_func")
.behavior(FunctionBehavior::Immutable);Sourcepub fn security(self, security: FunctionSecurity) -> Self
pub fn security(self, security: FunctionSecurity) -> Self
Set security context (DEFINER/INVOKER)
§Examples
use reinhardt_query::types::function::{FunctionDef, FunctionSecurity};
let func = FunctionDef::new("my_func")
.security(FunctionSecurity::Definer);Trait Implementations§
Source§impl Clone for FunctionDef
impl Clone for FunctionDef
Source§fn clone(&self) -> FunctionDef
fn clone(&self) -> FunctionDef
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for FunctionDef
impl !RefUnwindSafe for FunctionDef
impl !Send for FunctionDef
impl !Sync for FunctionDef
impl Unpin for FunctionDef
impl UnsafeUnpin for FunctionDef
impl !UnwindSafe for FunctionDef
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
Mutably borrows from an owned value. Read more