pub struct RelationshipDefinition {
pub name: String,
pub display_name: String,
pub description: String,
pub inverse: Option<String>,
pub symmetric: bool,
pub cardinality: Cardinality,
pub source_types: Vec<String>,
pub target_types: Vec<String>,
pub built_in: bool,
pub color: Option<String>,
pub icon: Option<String>,
}Expand description
Defines a relationship type and its constraints
Fields§
§name: StringUnique identifier for this relationship type (lowercase, no spaces)
display_name: StringHuman-readable display name
description: StringDescription of what this relationship means
inverse: Option<String>The inverse relationship name (if any) e.g., “parent” has inverse “child”
symmetric: boolWhether this relationship is symmetric (A->B implies B->A with same type) e.g., “duplicate” is symmetric
cardinality: CardinalityCardinality constraints
source_types: Vec<String>Source type constraints (which requirement types can be the source) Empty means all types allowed
target_types: Vec<String>Target type constraints (which requirement types can be the target) Empty means all types allowed
built_in: boolWhether this is a built-in relationship (cannot be deleted)
color: Option<String>Color for visualization (optional, hex format e.g., “#ff6b6b”)
icon: Option<String>Icon/symbol for the relationship (optional)
Implementations§
Source§impl RelationshipDefinition
impl RelationshipDefinition
Sourcepub fn built_in(name: &str, display_name: &str, description: &str) -> Self
pub fn built_in(name: &str, display_name: &str, description: &str) -> Self
Create a built-in relationship definition
Sourcepub fn with_inverse(self, inverse: &str) -> Self
pub fn with_inverse(self, inverse: &str) -> Self
Set the inverse relationship
Sourcepub fn with_symmetric(self, symmetric: bool) -> Self
pub fn with_symmetric(self, symmetric: bool) -> Self
Set as symmetric
Sourcepub fn with_cardinality(self, cardinality: Cardinality) -> Self
pub fn with_cardinality(self, cardinality: Cardinality) -> Self
Set the cardinality
Sourcepub fn with_source_types(self, types: Vec<String>) -> Self
pub fn with_source_types(self, types: Vec<String>) -> Self
Set source type constraints
Sourcepub fn with_target_types(self, types: Vec<String>) -> Self
pub fn with_target_types(self, types: Vec<String>) -> Self
Set target type constraints
Sourcepub fn with_color(self, color: &str) -> Self
pub fn with_color(self, color: &str) -> Self
Set the color
Sourcepub fn defaults() -> Vec<RelationshipDefinition>
pub fn defaults() -> Vec<RelationshipDefinition>
Get the default built-in relationship definitions
Sourcepub fn allows_source_type(&self, req_type: &RequirementType) -> bool
pub fn allows_source_type(&self, req_type: &RequirementType) -> bool
Check if a source requirement type is allowed
Sourcepub fn allows_target_type(&self, req_type: &RequirementType) -> bool
pub fn allows_target_type(&self, req_type: &RequirementType) -> bool
Check if a target requirement type is allowed
Trait Implementations§
Source§impl Clone for RelationshipDefinition
impl Clone for RelationshipDefinition
Source§fn clone(&self) -> RelationshipDefinition
fn clone(&self) -> RelationshipDefinition
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RelationshipDefinition
impl Debug for RelationshipDefinition
Source§impl<'de> Deserialize<'de> for RelationshipDefinition
impl<'de> Deserialize<'de> for RelationshipDefinition
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for RelationshipDefinition
impl PartialEq for RelationshipDefinition
Source§impl Serialize for RelationshipDefinition
impl Serialize for RelationshipDefinition
Source§impl TS for RelationshipDefinition
impl TS for RelationshipDefinition
Source§type WithoutGenerics = RelationshipDefinition
type WithoutGenerics = RelationshipDefinition
WithoutGenerics should just be Self.
If the type does have generic parameters, then all generic parameters must be replaced with
a dummy type, e.g ts_rs::Dummy or ().
The only requirement for these dummy types is that EXPORT_TO must be None. Read moreSource§type OptionInnerType = RelationshipDefinition
type OptionInnerType = RelationshipDefinition
std::option::Option<T>, then this associated type is set to T.
All other implementations of TS should set this type to Self instead.Source§fn docs() -> Option<String>
fn docs() -> Option<String>
TS is derived, docs are
automatically read from your doc comments or #[doc = ".."] attributesSource§fn decl_concrete() -> String
fn decl_concrete() -> String
TS::decl().
If this type is not generic, then this function is equivalent to TS::decl().Source§fn decl() -> String
fn decl() -> String
type User = { user_id: number, ... }.
This function will panic if the type has no declaration. Read moreSource§fn inline() -> String
fn inline() -> String
{ user_id: number }.
This function will panic if the type cannot be inlined.Source§fn inline_flattened() -> String
fn inline_flattened() -> String
This function will panic if the type cannot be flattened.
Source§fn visit_generics(v: &mut impl TypeVisitor)where
Self: 'static,
fn visit_generics(v: &mut impl TypeVisitor)where
Self: 'static,
Source§fn output_path() -> Option<PathBuf>
fn output_path() -> Option<PathBuf>
T should be exported.The returned path does not include the base directory from
TS_RS_EXPORT_DIR. Read moreSource§fn visit_dependencies(v: &mut impl TypeVisitor)where
Self: 'static,
fn visit_dependencies(v: &mut impl TypeVisitor)where
Self: 'static,
Source§fn dependencies() -> Vec<Dependency>where
Self: 'static,
fn dependencies() -> Vec<Dependency>where
Self: 'static,
Source§fn export() -> Result<(), ExportError>where
Self: 'static,
fn export() -> Result<(), ExportError>where
Self: 'static,
TS::export_all. Read moreSource§fn export_all() -> Result<(), ExportError>where
Self: 'static,
fn export_all() -> Result<(), ExportError>where
Self: 'static,
To export only this type, without its dependencies, use
TS::export. Read moreSource§fn export_all_to(out_dir: impl AsRef<Path>) -> Result<(), ExportError>where
Self: 'static,
fn export_all_to(out_dir: impl AsRef<Path>) -> Result<(), ExportError>where
Self: 'static,
To export only this type, without its dependencies, use
TS::export. Read moreSource§fn export_to_string() -> Result<String, ExportError>where
Self: 'static,
fn export_to_string() -> Result<String, ExportError>where
Self: 'static,
impl Eq for RelationshipDefinition
impl StructuralPartialEq for RelationshipDefinition
Auto Trait Implementations§
impl Freeze for RelationshipDefinition
impl RefUnwindSafe for RelationshipDefinition
impl Send for RelationshipDefinition
impl Sync for RelationshipDefinition
impl Unpin for RelationshipDefinition
impl UnsafeUnpin for RelationshipDefinition
impl UnwindSafe for RelationshipDefinition
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.