pub struct Object {
pub name: String,
pub attributes: Vec<Attribute>,
pub docstring: String,
pub term: Option<String>,
pub mixins: Vec<String>,
pub position: Option<Position>,
}Expand description
Represents an object with a name, attributes, docstring, and an optional term.
Fields§
§name: StringName of the object.
attributes: Vec<Attribute>List of attributes associated with the object.
docstring: StringDocumentation string for the object.
term: Option<String>Optional term associated with the object.
mixins: Vec<String>Other objects that this object gets mixed in with.
position: Option<Position>The line number of the object
Implementations§
Source§impl Object
impl Object
Sourcepub fn add_attribute(&mut self, attribute: Attribute)
pub fn add_attribute(&mut self, attribute: Attribute)
Adds an attribute to the object.
§Arguments
attribute- An instance ofAttributeto be added to the object’s attributes.
Sourcepub fn set_docstring(&mut self, docstring: String)
pub fn set_docstring(&mut self, docstring: String)
Sets the docstring for the object.
§Arguments
docstring- A string representing the documentation string for the object.
Sourcepub fn set_position(&mut self, position: Position)
pub fn set_position(&mut self, position: Position)
Sourcepub fn get_last_attribute(&mut self) -> Option<&mut Attribute>
pub fn get_last_attribute(&mut self) -> Option<&mut Attribute>
Sourcepub fn create_new_attribute(&mut self, name: String, required: bool)
pub fn create_new_attribute(&mut self, name: String, required: bool)
Creates and adds a new attribute to the object.
§Arguments
name- A string representing the name of the attribute.required- A boolean indicating whether the attribute is required.
Sourcepub fn has_attributes(&self) -> bool
pub fn has_attributes(&self) -> bool
Checks if the object has any attributes.
§Returns
bool-trueif the object has attributes,falseotherwise.
Sourcepub fn has_any_terms(&self) -> bool
pub fn has_any_terms(&self) -> bool
Checks if any attribute of the object has a term.
§Returns
bool-trueif any attribute has a term,falseotherwise.
Sourcepub fn sort_attrs_by_required(&mut self)
pub fn sort_attrs_by_required(&mut self)
Sorts the attributes of the object by their required field in descending order.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Object
impl<'de> Deserialize<'de> for Object
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<ClassDefinition> for Object
Implements conversion from LinkML ClassDefinition to Object.
impl From<ClassDefinition> for Object
Implements conversion from LinkML ClassDefinition to Object.
Source§fn from(class: ClassDefinition) -> Self
fn from(class: ClassDefinition) -> Self
Converts a LinkML ClassDefinition into an internal Object representation.
This conversion handles:
- Class metadata (name, description, URI)
- Local attribute definitions
- Slot usage patterns and constraints
§Arguments
class- The LinkML ClassDefinition to convert
§Returns
An Object representing the class in the internal model format
Source§impl From<Object> for ClassDefinition
Implements conversion from Object to LinkML ClassDefinition.
impl From<Object> for ClassDefinition
Implements conversion from Object to LinkML ClassDefinition.
Source§fn from(obj: Object) -> Self
fn from(obj: Object) -> Self
Converts an Object into a LinkML ClassDefinition.
This conversion process handles:
- Converting attributes to LinkML format
- Setting up slot usage for pattern constraints
- Preserving documentation and URI terms
- Maintaining inheritance relationships
- Managing attribute constraints and validations
Source§impl TryFrom<&Object> for SchemaObject
impl TryFrom<&Object> for SchemaObject
Source§impl TryFrom<&Object> for SchemaType
impl TryFrom<&Object> for SchemaType
Source§impl TryFrom<SchemaObject> for Object
Converts a JSON Schema object to an Object
impl TryFrom<SchemaObject> for Object
Converts a JSON Schema object to an Object
This implementation handles the conversion of a schema object’s properties to attributes, and processes required fields.