Trait typedb_driver::transaction::concept::api::ThingTypeAPI
source · pub trait ThingTypeAPI: Sync + Send {
Show 18 methods
// Required methods
fn label(&self) -> &str;
fn is_abstract(&self) -> bool;
fn is_root(&self) -> bool;
fn to_thing_type_cloned(&self) -> ThingType;
fn is_deleted<'tx>(
&self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<bool>>;
// Provided methods
fn delete<'tx>(
&mut self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result> { ... }
fn set_label<'tx>(
&mut self,
transaction: &'tx Transaction<'_>,
new_label: String
) -> BoxPromise<'tx, Result> { ... }
fn set_abstract<'tx>(
&mut self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result> { ... }
fn unset_abstract<'tx>(
&mut self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result> { ... }
fn get_owns<'tx>(
&self,
transaction: &'tx Transaction<'_>,
value_type: Option<ValueType>,
transitivity: Transitivity,
annotations: Vec<Annotation>
) -> Result<BoxStream<'tx, Result<AttributeType>>> { ... }
fn get_owns_overridden<'tx>(
&self,
transaction: &'tx Transaction<'_>,
overridden_attribute_type: AttributeType
) -> BoxPromise<'tx, Result<Option<AttributeType>>> { ... }
fn set_owns<'tx>(
&mut self,
transaction: &'tx Transaction<'_>,
attribute_type: AttributeType,
overridden_attribute_type: Option<AttributeType>,
annotations: Vec<Annotation>
) -> BoxPromise<'tx, Result> { ... }
fn unset_owns<'tx>(
&mut self,
transaction: &'tx Transaction<'_>,
attribute_type: AttributeType
) -> BoxPromise<'tx, Result> { ... }
fn get_plays<'tx>(
&self,
transaction: &'tx Transaction<'_>,
transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<RoleType>>> { ... }
fn get_plays_overridden<'tx>(
&self,
transaction: &'tx Transaction<'_>,
overridden_role_type: RoleType
) -> BoxPromise<'tx, Result<Option<RoleType>>> { ... }
fn set_plays<'tx>(
&mut self,
transaction: &'tx Transaction<'_>,
role_type: RoleType,
overridden_role_type: Option<RoleType>
) -> BoxPromise<'tx, Result> { ... }
fn unset_plays<'tx>(
&mut self,
transaction: &'tx Transaction<'_>,
role_type: RoleType
) -> BoxPromise<'tx, Result> { ... }
fn get_syntax<'tx>(
&self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<String>> { ... }
}
Required Methods§
sourcefn is_abstract(&self) -> bool
fn is_abstract(&self) -> bool
Checks if the type is prevented from having data instances (i.e. abstract
).
§Examples
thing_type.is_abstract();
fn to_thing_type_cloned(&self) -> ThingType
sourcefn is_deleted<'tx>(
&self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<bool>>
fn is_deleted<'tx>( &self, transaction: &'tx Transaction<'_> ) -> BoxPromise<'tx, Result<bool>>
Provided Methods§
sourcefn delete<'tx>(
&mut self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result>
fn delete<'tx>( &mut self, transaction: &'tx Transaction<'_> ) -> BoxPromise<'tx, Result>
sourcefn set_label<'tx>(
&mut self,
transaction: &'tx Transaction<'_>,
new_label: String
) -> BoxPromise<'tx, Result>
fn set_label<'tx>( &mut self, transaction: &'tx Transaction<'_>, new_label: String ) -> BoxPromise<'tx, Result>
sourcefn set_abstract<'tx>(
&mut self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result>
fn set_abstract<'tx>( &mut self, transaction: &'tx Transaction<'_> ) -> BoxPromise<'tx, Result>
sourcefn unset_abstract<'tx>(
&mut self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result>
fn unset_abstract<'tx>( &mut self, transaction: &'tx Transaction<'_> ) -> BoxPromise<'tx, Result>
sourcefn get_owns<'tx>(
&self,
transaction: &'tx Transaction<'_>,
value_type: Option<ValueType>,
transitivity: Transitivity,
annotations: Vec<Annotation>
) -> Result<BoxStream<'tx, Result<AttributeType>>>
fn get_owns<'tx>( &self, transaction: &'tx Transaction<'_>, value_type: Option<ValueType>, transitivity: Transitivity, annotations: Vec<Annotation> ) -> Result<BoxStream<'tx, Result<AttributeType>>>
Retrieves AttributeType
that the instances of this ThingType
are allowed to own
directly or via inheritance.
§Arguments
transaction
– The current transactionvalue_type
– If specified, only attribute types of thisValueType
will be retrieved.transitivity
–Transitivity::Transitive
for direct and inherited ownership,Transitivity::Explicit
for direct ownership onlyannotations
– Only retrieve attribute types owned with annotations.
§Examples
thing_type.get_owns(transaction, Some(value_type), Transitivity::Explicit, vec![Annotation::Key]).await;
sourcefn get_owns_overridden<'tx>(
&self,
transaction: &'tx Transaction<'_>,
overridden_attribute_type: AttributeType
) -> BoxPromise<'tx, Result<Option<AttributeType>>>
fn get_owns_overridden<'tx>( &self, transaction: &'tx Transaction<'_>, overridden_attribute_type: AttributeType ) -> BoxPromise<'tx, Result<Option<AttributeType>>>
Retrieves an AttributeType
, ownership of which is overridden for this ThingType
by a given attribute_type
.
§Arguments
transaction
– The current transactionoverridden_attribute_type
– TheAttributeType
that overrides requestedAttributeType
§Examples
thing_type.get_owns_overridden(transaction, attribute_type).await;
sourcefn set_owns<'tx>(
&mut self,
transaction: &'tx Transaction<'_>,
attribute_type: AttributeType,
overridden_attribute_type: Option<AttributeType>,
annotations: Vec<Annotation>
) -> BoxPromise<'tx, Result>
fn set_owns<'tx>( &mut self, transaction: &'tx Transaction<'_>, attribute_type: AttributeType, overridden_attribute_type: Option<AttributeType>, annotations: Vec<Annotation> ) -> BoxPromise<'tx, Result>
Allows the instances of this ThingType
to own the given AttributeType
.
§Arguments
transaction
– The current transactionattribute_type
– TheAttributeType
to be owned by the instances of this type.overridden_attribute_type
– TheAttributeType
that this attribute ownership overrides, if applicable.annotations
– Adds annotations to the ownership.
§Examples
thing_type.set_owns(transaction, attribute_type, Some(overridden_type), vec![Annotation::Key]).await;
sourcefn unset_owns<'tx>(
&mut self,
transaction: &'tx Transaction<'_>,
attribute_type: AttributeType
) -> BoxPromise<'tx, Result>
fn unset_owns<'tx>( &mut self, transaction: &'tx Transaction<'_>, attribute_type: AttributeType ) -> BoxPromise<'tx, Result>
sourcefn get_plays<'tx>(
&self,
transaction: &'tx Transaction<'_>,
transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<RoleType>>>
fn get_plays<'tx>( &self, transaction: &'tx Transaction<'_>, transitivity: Transitivity ) -> Result<BoxStream<'tx, Result<RoleType>>>
Retrieves all direct and inherited (or direct only) roles that are allowed to be played
by the instances of this ThingType
.
§Arguments
transaction
– The current transactiontransitivity
–Transitivity::Transitive
for direct and indirect playing,Transitivity::Explicit
for direct playing only
§Examples
thing_type.get_plays(transaction, Transitivity::Explicit).await;
sourcefn get_plays_overridden<'tx>(
&self,
transaction: &'tx Transaction<'_>,
overridden_role_type: RoleType
) -> BoxPromise<'tx, Result<Option<RoleType>>>
fn get_plays_overridden<'tx>( &self, transaction: &'tx Transaction<'_>, overridden_role_type: RoleType ) -> BoxPromise<'tx, Result<Option<RoleType>>>
sourcefn set_plays<'tx>(
&mut self,
transaction: &'tx Transaction<'_>,
role_type: RoleType,
overridden_role_type: Option<RoleType>
) -> BoxPromise<'tx, Result>
fn set_plays<'tx>( &mut self, transaction: &'tx Transaction<'_>, role_type: RoleType, overridden_role_type: Option<RoleType> ) -> BoxPromise<'tx, Result>
Allows the instances of this ThingType
to play the given role.
§Arguments
transaction
– The current transactionrole_type
– The role to be played by the instances of this typeoverridden_role_type
– The role type that this role overrides, if applicable
§Examples
thing_type.set_plays(transaction, role_type, None).await;