Skip to main content

Attribute

Struct Attribute 

Source
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: String

The name of the attribute.

§is_array: bool

Indicates if the attribute is an array.

§is_id: bool

Is an identifier or not

§dtypes: Vec<String>

Data types associated with the attribute.

§docstring: String

Documentation 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: bool

Indicates if the attribute is required.

§default: Option<DataType>

Default value for the attribute.

§xml: Option<XMLType>

XML type information for the attribute.

§is_enum: bool

Is 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

Source

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.
Source

pub fn set_docstring(&mut self, docstring: String)

Sets the documentation string for the attribute.

§Arguments
  • docstring - The documentation string to set.
Source

pub fn set_position(&mut self, position: Position)

Sets the line number of the attribute.

§Arguments
  • position - The position to set.
Source

pub fn add_option(&mut self, option: RawOption) -> Result<(), Box<dyn Error>>

Adds an option to the attribute.

§Arguments
  • option - The option to add.
Source

pub fn to_json_schema(&self) -> String

Converts the attribute to a JSON schema.

§Returns

A JSON string representing the attribute schema.

Source

pub fn has_term(&self) -> bool

Checks if the attribute has an associated term.

§Returns

true if the attribute has a term, false otherwise.

Source

pub fn set_xml(&mut self, xml: XMLType)

Sets the XML type for the attribute.

§Arguments
  • xml - The XML type to set.

Trait Implementations§

Source§

impl Clone for Attribute

Source§

fn clone(&self) -> Attribute

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Attribute

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Attribute

Source§

fn default() -> Attribute

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Attribute

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<&Attribute> for Option<Item>

Specific case for the items field in the JSON schema.

Source§

fn from(attr: &Attribute) -> Self

Converts an Attribute into an Option<Item>.

§Arguments
  • attr - A reference to the Attribute.
§Returns

An Option<Item> representing the attribute’s items.

Source§

impl From<&Attribute> for Vec<Item>

Source§

fn from(attr: &Attribute) -> Self

Converts an Attribute into a Vec<Item>.

§Arguments
  • attr - A reference to the Attribute.
§Returns

A Vec<Item> representing the attribute’s items.

Source§

impl From<Attribute> for AttributeDefinition

Implements conversion from Attribute to LinkML AttributeDefinition.

Source§

fn from(attribute: Attribute) -> Self

Converts an Attribute into a LinkML AttributeDefinition.

This conversion preserves:

  • Array/multivalued status
  • Data type (range)
  • Documentation
  • ID status
  • Required status
  • Minimum and maximum values
  • Examples
  • Term mappings
Source§

impl From<AttributeDefinition> for Attribute

Implements conversion from LinkML AttributeDefinition to Attribute.

Source§

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 PartialEq for Attribute

Source§

fn eq(&self, other: &Attribute) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Attribute

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TryFrom<&Attribute> for DataType

Source§

fn try_from(attr: &Attribute) -> Result<Self, Self::Error>

Attempts to convert an Attribute into a DataType.

§Arguments
  • attr - A reference to the Attribute.
§Returns

A Result containing the DataType or an error message.

§Errors

Returns an error if the dtypes vector in the attribute is empty.

Source§

type Error = String

The type returned in the event of a conversion error.
Source§

impl TryFrom<&Attribute> for Property

Source§

fn try_from(attr: &Attribute) -> Result<Self, Self::Error>

Attempts to convert an Attribute into a Property.

§Arguments
  • attr - A reference to the Attribute.
§Returns

A Result containing the Property or an error message.

Source§

type Error = String

The type returned in the event of a conversion error.
Source§

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)
Source§

type Error = Box<dyn Error>

The type returned in the event of a conversion error.
Source§

fn try_from(property: Property) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl StructuralPartialEq for Attribute

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,