Skip to main content

DdlPolicy

Struct DdlPolicy 

Source
pub struct DdlPolicy {
    pub allow_create: bool,
    pub allow_drop: bool,
    pub allow_alter: bool,
    pub allow_truncate: bool,
    pub allow_create_index: bool,
    pub allow_drop_index: bool,
}
Expand description

DDL 操作策略,控制允许的 DDL 操作类型。

Fields§

§allow_create: bool

是否允许 CREATE

§allow_drop: bool

是否允许 DROP

§allow_alter: bool

是否允许 ALTER

§allow_truncate: bool

是否允许 TRUNCATE

§allow_create_index: bool

是否允许 CREATE INDEX

§allow_drop_index: bool

是否允许 DROP INDEX

Implementations§

Source§

impl DdlPolicy

Source

pub fn permissive() -> Self

创建允许所有 DDL 操作的策略(生产环境慎用)。

Source

pub fn read_only() -> Self

创建只读策略(禁止所有 DDL)。

Source

pub fn safe_evolution() -> Self

创建允许 CREATE 和 ALTER 但禁止 DROP 和 TRUNCATE 的策略。

Source

pub fn validate(&self, sql: &str) -> ValidationResult

根据策略校验 DDL 语句是否被允许。

Trait Implementations§

Source§

impl Clone for DdlPolicy

Source§

fn clone(&self) -> DdlPolicy

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 Debug for DdlPolicy

Source§

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

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

impl Default for DdlPolicy

Source§

fn default() -> DdlPolicy

Returns the “default value” for a type. 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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.