Skip to main content

TableDefinition

Struct TableDefinition 

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

不可变的数据表定义。

Implementations§

Source§

impl TableDefinition

Source

pub fn name(&self) -> &str

返回数据库表名。

Source

pub fn datasource(&self) -> &DatasourceId

返回表所属逻辑数据源。

Source

pub fn label(&self) -> &str

返回展示名称。

Source

pub fn primary_key(&self) -> &str

返回主键字段名。

Source

pub fn primary_keys(&self) -> &[String]

返回完整主键列(复合主键时大于一个元素)。

Source

pub fn field_count(&self) -> usize

返回字段数量。

Source

pub fn field(&self, name: &str) -> Option<FieldMetadata<'_>>

按数据库字段名读取元数据。

Source

pub fn fields(&self) -> Vec<FieldMetadata<'_>>

按字段名排序返回全部字段元数据。

Source

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

返回软删除字段名。

Source

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

返回唯一租户隔离字段;表未声明租户字段时返回 None。

Source

pub fn input_schema(&self) -> Value

生成供 API catalog 使用的全局写入侧 JSON Schema。

该 schema 是所有角色可写字段的并集;面向当前请求返回结构时应使用 Self::input_schema_for_roles。

Source

pub fn output_schema(&self) -> Value

生成供 API catalog 使用的全局读取侧 JSON Schema。

该 schema 是所有角色可读字段的并集;面向当前请求返回结构时应使用 Self::output_schema_for_roles。

Source

pub fn input_schema_for_roles(&self, roles: &HashSet<String>) -> Value

按当前用户角色生成写入侧 JSON Schema。

Source

pub fn output_schema_for_roles(&self, roles: &HashSet<String>) -> Value

按当前用户角色生成读取侧 JSON Schema。

Source

pub fn validate_schema( &self, columns: &[SchemaColumn], ) -> SchemaValidationReport

校验实际数据库列是否兼容当前表定义。

Source

pub fn bind(&self, pool: Arc<MySqlPool>) -> TableHandle

将表定义绑定到 MySQL 连接池(兼容入口)。

内部会包装为 AnyPool::MySql;需要 PostgreSQL 或其他运行时后端时请使用 TableDefinition::bind_pool。

Source

pub fn bind_pool(&self, pool: AnyPool) -> TableHandle

将表定义绑定到任意受支持的数据库连接池(沿用表声明的数据源)。

Source

pub fn bind_datasource(&self, datasource: &Datasource) -> TableHandle

将表定义绑定到注册表中的具名数据源(推荐入口)。

Source

pub fn bind_source_pool(&self, pool: PoolHandle) -> TableHandle

将表定义绑定到带逻辑数据源身份的连接池句柄。

Trait Implementations§

Source§

impl Clone for TableDefinition

Source§

fn clone(&self) -> Self

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 TableDefinition

Source§

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

Formats the value using the given formatter. 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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. 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 = !

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

fn try_from(value: U) -> Result<T, !>

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