pub struct Attribute {Show 13 fields
pub name: String,
pub is_array: bool,
pub is_id: bool,
pub dtypes: Vec<String>,
pub docstring: String,
pub options: Vec<AttrOption>,
pub term: Option<String>,
pub required: bool,
pub default: Option<DataType>,
pub xml: Option<XMLType>,
pub is_enum: bool,
pub position: Option<Position>,
pub import_prefix: Option<String>,
}Expand description
Represents an attribute with various properties and options.
Fields§
§name: StringThe name of the attribute.
is_array: boolIndicates if the attribute is an array.
is_id: boolIs an identifier or not
dtypes: Vec<String>Data types associated with the attribute.
docstring: StringDocumentation string for the attribute.
options: Vec<AttrOption>List of additional options for the attribute.
term: Option<String>Term associated with the attribute, if any.
required: boolIndicates if the attribute is required.
default: Option<DataType>Default value for the attribute.
xml: Option<XMLType>XML type information for the attribute.
is_enum: boolIs an enumeration or not
position: Option<Position>The line number of the attribute
import_prefix: Option<String>The prefix of the attribute, if it is an import
Implementations§
Source§impl Attribute
impl Attribute
Sourcepub fn new(name: String, required: bool) -> Self
pub fn new(name: String, required: bool) -> Self
Creates a new Attribute with the given name and required status.
§Arguments
name- The name of the attribute.required- Indicates if the attribute is required.
Sourcepub fn set_docstring(&mut self, docstring: String)
pub fn set_docstring(&mut self, docstring: String)
Sets the documentation string for the attribute.
§Arguments
docstring- The documentation string to set.
Sourcepub fn set_position(&mut self, position: Position)
pub fn set_position(&mut self, position: Position)
Sourcepub fn to_json_schema(&self) -> String
pub fn to_json_schema(&self) -> String
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Attribute
impl<'de> Deserialize<'de> for Attribute
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 From<Attribute> for AttributeDefinition
Implements conversion from Attribute to LinkML AttributeDefinition.
impl From<Attribute> for AttributeDefinition
Implements conversion from Attribute to LinkML AttributeDefinition.
Source§impl From<AttributeDefinition> for Attribute
Implements conversion from LinkML AttributeDefinition to Attribute.
impl From<AttributeDefinition> for Attribute
Implements conversion from LinkML AttributeDefinition to Attribute.
Source§fn from(attr: AttributeDefinition) -> Self
fn from(attr: AttributeDefinition) -> Self
Converts a LinkML AttributeDefinition into an internal Attribute representation.
This conversion preserves:
- Documentation
- Data type/range
- Cardinality (multivalued status)
- Identifier status
- Required status
- URI/term mapping
§Arguments
attr- The LinkML AttributeDefinition to convert
§Returns
An Attribute representing the slot in the internal model format
Source§impl TryFrom<&Attribute> for DataType
impl TryFrom<&Attribute> for DataType
Source§impl TryFrom<&Attribute> for Property
impl TryFrom<&Attribute> for Property
Source§impl TryFrom<Property> for Attribute
Converts a JSON Schema property to an Attribute
impl TryFrom<Property> for Attribute
Converts a JSON Schema property to an Attribute
This implementation handles various property types including:
- Array properties with items
- Properties with direct data types
- Properties with references
- Properties with oneOf (multiple possible types)