EntitiesRelation

Struct EntitiesRelation 

Source
pub struct EntitiesRelation<'a, D> { /* private fields */ }
Expand description

Represents the relationship between entities in the database, used for validation.

§Type Parameters

  • D - The data type of the primary key

表示数据库中的实体之间的关系,用于验证。

§类型参数

  • D - 主键的数据类型

Implementations§

Source§

impl<'a, D> EntitiesRelation<'a, D>
where D: PartialEq + Debug,

Implementation of the EntitiesRelation struct. EntitiesRelation结构体关系的实现。

Source

pub fn validate(&self, values: Vec<&'a D>) -> Result<(), Error>

Validates the relation between entities.

It checks whether the number of values matches the relation type and whether the values match the primary key.

§Arguments
  • values - A vector of references to values to validate
§Returns
  • Ok if validation passes
  • Err with a detailed error if validation fails

验证实体之间的关系。

检查值的数量是否与关系类型匹配,以及值是否与主键匹配。

§参数
  • values - 需要验证的值的引用向量
§返回值
  • 如果验证通过则返回Ok
  • 如果验证失败则返回包含详细错误信息的Err
Source

pub fn one_to_one(primary_key: &'a D) -> Self

Creates a new EntitiesRelation instance for one-to-one relations.

This relation type allows a single entity to be associated with another single entity.

§Arguments
  • primary_key - The primary key of the entity
§Returns

A new EntitiesRelation instance with OneToOne relationship type

创建一对一关系的EntitiesRelation实例。

此关系类型允许单个实体与另一个单个实体关联。

§参数
  • primary_key - 实体的主键
§返回值

具有一对一关系类型的新EntitiesRelation实例

Source

pub fn one_to_many(primary_key: &'a D) -> Self

Creates a new EntitiesRelation instance for one-to-many relations.

This relation type allows one entity to be associated with multiple other entities.

§Arguments
  • primary_key - The primary key of the entity
§Returns

A new EntitiesRelation instance with OneToMany relationship type

创建一对多关系的EntitiesRelation实例。

此关系类型允许一个实体与多个其他实体关联。

§参数
  • primary_key - 实体的主键
§返回值

具有一对多关系类型的新EntitiesRelation实例

Source

pub fn many_to_many(primary_key: &'a D) -> Self

Creates a new EntitiesRelation instance for many-to-many relations.

This relation type allows multiple entities to be associated with multiple other entities.

§Arguments
  • primary_key - The primary key of the entity
§Returns

A new EntitiesRelation instance with ManyToMany relationship type

创建多对多关系的EntitiesRelation实例。

此关系类型允许多个实体与多个其他实体关联。

§参数
  • primary_key - 实体的主键
§返回值

具有多对多关系类型的新EntitiesRelation实例

Auto Trait Implementations§

§

impl<'a, D> Freeze for EntitiesRelation<'a, D>

§

impl<'a, D> RefUnwindSafe for EntitiesRelation<'a, D>
where D: RefUnwindSafe,

§

impl<'a, D> Send for EntitiesRelation<'a, D>
where D: Sync,

§

impl<'a, D> Sync for EntitiesRelation<'a, D>
where D: Sync,

§

impl<'a, D> Unpin for EntitiesRelation<'a, D>

§

impl<'a, D> UnwindSafe for EntitiesRelation<'a, D>
where D: RefUnwindSafe,

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> 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, 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
Source§

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