Skip to main content

ProductDomainExt

Trait ProductDomainExt 

Source
pub trait ProductDomainExt {
    // Required methods
    fn add_product_domain(
        &mut self,
        name: impl Into<String>,
        product: ProductDomain,
    ) -> Result<(), AdapterError>;
    fn get_product_domain(&self, name: &str) -> Option<&ProductDomain>;
    fn list_product_domains(&self) -> Vec<(&str, &ProductDomain)>;
}
Expand description

Extension trait for SymbolTable to support product domains.

Required Methods§

Source

fn add_product_domain( &mut self, name: impl Into<String>, product: ProductDomain, ) -> Result<(), AdapterError>

Add a product domain to the symbol table.

The product domain’s cardinality is computed from its components.

§Examples
use tensorlogic_adapters::{SymbolTable, DomainInfo, ProductDomain, ProductDomainExt};

let mut table = SymbolTable::new();
table.add_domain(DomainInfo::new("Person", 100)).unwrap();
table.add_domain(DomainInfo::new("Location", 50)).unwrap();

let product = ProductDomain::binary("Person", "Location");
table.add_product_domain("PersonAtLocation", product).unwrap();

let domain = table.get_domain("PersonAtLocation").unwrap();
assert_eq!(domain.cardinality, 5000);
Source

fn get_product_domain(&self, name: &str) -> Option<&ProductDomain>

Get a product domain by name.

Returns None if the domain doesn’t exist or is not a product domain.

Source

fn list_product_domains(&self) -> Vec<(&str, &ProductDomain)>

List all product domains in the symbol table.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§