pub trait ThingAPI: Sync + Send {
    // Required methods
    fn iid(&self) -> &IID;
    fn is_inferred(&self) -> bool;
    fn to_thing_cloned(&self) -> Thing;
    fn is_deleted<'tx>(
        &self,
        transaction: &'tx Transaction<'_>
    ) -> BoxPromise<'tx, Result<bool>>;

    // Provided methods
    fn delete<'tx>(
        &self,
        transaction: &'tx Transaction<'_>
    ) -> BoxPromise<'tx, Result> { ... }
    fn get_has<'tx>(
        &self,
        transaction: &'tx Transaction<'_>,
        attribute_types: Vec<AttributeType>,
        annotations: Vec<Annotation>
    ) -> Result<BoxStream<'tx, Result<Attribute>>> { ... }
    fn set_has<'tx>(
        &self,
        transaction: &'tx Transaction<'_>,
        attribute: Attribute
    ) -> BoxPromise<'tx, Result> { ... }
    fn unset_has<'tx>(
        &self,
        transaction: &'tx Transaction<'_>,
        attribute: Attribute
    ) -> BoxPromise<'tx, Result> { ... }
    fn get_relations<'tx>(
        &self,
        transaction: &'tx Transaction<'_>,
        role_types: Vec<RoleType>
    ) -> Result<BoxStream<'tx, Result<Relation>>> { ... }
    fn get_playing<'tx>(
        &self,
        transaction: &'tx Transaction<'_>
    ) -> Result<BoxStream<'tx, Result<RoleType>>> { ... }
}

Required Methods§

source

fn iid(&self) -> &IID

Retrieves the unique id of the Thing.

§Examples
thing.iid();
source

fn is_inferred(&self) -> bool

Checks if this Thing is inferred by a [Reasoning Rule].

§Examples
thing.is_inferred();
source

fn to_thing_cloned(&self) -> Thing

source

fn is_deleted<'tx>( &self, transaction: &'tx Transaction<'_> ) -> BoxPromise<'tx, Result<bool>>

Checks if this Thing is deleted.

§Arguments
  • transaction – The current transaction
§Examples
thing.is_deleted(transaction).await;

Provided Methods§

source

fn delete<'tx>( &self, transaction: &'tx Transaction<'_> ) -> BoxPromise<'tx, Result>

Deletes this Thing.

§Arguments
  • transaction – The current transaction
§Examples
thing.delete(transaction).await;
source

fn get_has<'tx>( &self, transaction: &'tx Transaction<'_>, attribute_types: Vec<AttributeType>, annotations: Vec<Annotation> ) -> Result<BoxStream<'tx, Result<Attribute>>>

Retrieves the Attributes that this Thing owns. Optionally, filtered by an AttributeType or a list of AttributeTypes. Optionally, filtered by Annotations.

§Arguments
  • transaction – The current transaction
  • attribute_type – The AttributeType to filter the attributes by
  • attribute_types – The AttributeTypes to filter the attributes by
  • annotations – Only retrieve attributes with all given Annotations
§Examples
thing.get_has(transaction, attribute_type, annotations=vec![Annotation::Key]);
source

fn set_has<'tx>( &self, transaction: &'tx Transaction<'_>, attribute: Attribute ) -> BoxPromise<'tx, Result>

Assigns an Attribute to be owned by this Thing.

§Arguments
  • transaction – The current transaction
  • attribute – The Attribute to be owned by this Thing.
§Examples
thing.set_has(transaction, attribute).await;
source

fn unset_has<'tx>( &self, transaction: &'tx Transaction<'_>, attribute: Attribute ) -> BoxPromise<'tx, Result>

Unassigns an Attribute from this Thing.

§Arguments
  • transaction – The current transaction
  • attribute – The Attribute to be disowned from this Thing.
§Examples
thing.unset_has(transaction, attribute).await;
source

fn get_relations<'tx>( &self, transaction: &'tx Transaction<'_>, role_types: Vec<RoleType> ) -> Result<BoxStream<'tx, Result<Relation>>>

Retrieves all the Relations which this Thing plays a role in, optionally filtered by one or more given roles.

§Arguments
  • transaction – The current transaction
  • role_types – The list of roles to filter the relations by.
§Examples
thing.get_relations(transaction, role_types);
source

fn get_playing<'tx>( &self, transaction: &'tx Transaction<'_> ) -> Result<BoxStream<'tx, Result<RoleType>>>

Retrieves the roles that this Thing is currently playing.

§Arguments
  • transaction – The current transaction
§Examples
thing.get_playing(transaction);

Implementors§