pub struct RelationshipDef {
pub name: String,
pub target: String,
pub cardinality: Cardinality,
pub navigation: NavigationHint,
pub foreign_key: Option<String>,
pub inverse: Option<String>,
pub description: Option<String>,
}Expand description
A service-to-service relationship declaration.
Each service declares its own relationships independently. The inverse field
is a documentation hint, not a hard reference. Relationships carry two dimensions:
structural (cardinality) and presentational (navigation hint).
use ferro_projections::{RelationshipDef, Cardinality, NavigationHint};
let rel = RelationshipDef::new("customer", "customer", Cardinality::ManyToOne)
.foreign_key("customer_id")
.inverse("orders")
.navigation(NavigationHint::Link)
.description("Customer who placed this order");Fields§
§name: StringRelationship name (e.g., “customer”, “line_items”).
target: StringTarget service name (e.g., “customer”, “order_line_item”).
cardinality: CardinalityStructural cardinality of the relationship.
How the renderer should present this relationship.
foreign_key: Option<String>Foreign key field name on the owning side.
inverse: Option<String>Name of the inverse relationship on the target service.
description: Option<String>Human-readable description of the relationship.
Implementations§
Source§impl RelationshipDef
impl RelationshipDef
Sourcepub fn new(
name: impl Into<String>,
target: impl Into<String>,
cardinality: Cardinality,
) -> Self
pub fn new( name: impl Into<String>, target: impl Into<String>, cardinality: Cardinality, ) -> Self
Creates a new relationship definition with default navigation from cardinality.
Sourcepub fn foreign_key(self, fk: impl Into<String>) -> Self
pub fn foreign_key(self, fk: impl Into<String>) -> Self
Sets the foreign key field name.
Sourcepub fn inverse(self, inverse: impl Into<String>) -> Self
pub fn inverse(self, inverse: impl Into<String>) -> Self
Sets the inverse relationship name on the target service.
Overrides the default navigation hint.
Sourcepub fn description(self, desc: impl Into<String>) -> Self
pub fn description(self, desc: impl Into<String>) -> Self
Sets the relationship description.
Trait Implementations§
Source§impl Clone for RelationshipDef
impl Clone for RelationshipDef
Source§fn clone(&self) -> RelationshipDef
fn clone(&self) -> RelationshipDef
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RelationshipDef
impl Debug for RelationshipDef
Source§impl<'de> Deserialize<'de> for RelationshipDef
impl<'de> Deserialize<'de> for RelationshipDef
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 JsonSchema for RelationshipDef
impl JsonSchema for RelationshipDef
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read more