pub enum AttrOption {
Show 16 variants
Example(String),
MinimumValue(f64),
MaximumValue(f64),
MinItems(usize),
MaxItems(usize),
MinLength(usize),
MaxLength(usize),
Pattern(String),
Unique(bool),
MultipleOf(i32),
ExclusiveMinimum(f64),
ExclusiveMaximum(f64),
PrimaryKey(bool),
ReadOnly(bool),
Recommended(bool),
Other {
key: String,
value: String,
},
}Expand description
Represents an option for an attribute in a data model.
This enum provides a strongly-typed representation of various attribute options that can be used to configure and constrain attributes in a data model.
The options are grouped into several categories:
- JSON Schema validation options (e.g., minimum/maximum values, length constraints)
- SQL database options (e.g., primary key)
- LinkML specific options (e.g., readonly, recommended)
- Custom options via the
Othervariant
Variants§
Example(String)
MinimumValue(f64)
Specifies the minimum value for a numeric attribute
MaximumValue(f64)
Specifies the maximum value for a numeric attribute
MinItems(usize)
Specifies the minimum number of items for an array attribute
MaxItems(usize)
Specifies the maximum number of items for an array attribute
MinLength(usize)
Specifies the minimum length for a string attribute
MaxLength(usize)
Specifies the maximum length for a string attribute
Pattern(String)
Specifies a regular expression pattern that a string attribute must match
Unique(bool)
Specifies whether array items must be unique
MultipleOf(i32)
Specifies that a numeric value must be a multiple of this number
ExclusiveMinimum(f64)
Specifies an exclusive minimum value for a numeric attribute
ExclusiveMaximum(f64)
Specifies an exclusive maximum value for a numeric attribute
PrimaryKey(bool)
Indicates whether the attribute is a primary key in a database
ReadOnly(bool)
Indicates whether the attribute is read-only
Recommended(bool)
Indicates whether the attribute is recommended to be included
Other
Represents a custom option not covered by the predefined variants
Implementations§
Source§impl AttrOption
impl AttrOption
Sourcepub fn from_pair(key: &str, value: &str) -> Result<Self, Box<dyn Error>>
pub fn from_pair(key: &str, value: &str) -> Result<Self, Box<dyn Error>>
Creates a new AttrOption from a key-value pair.
This method attempts to parse the key and value into an appropriate AttrOption variant.
If the key matches a known option type, it will attempt to parse the value into the
appropriate type. If the key is not recognized, it will create an Other variant.
§Arguments
key- The string key identifying the option typevalue- The string value to be parsed into the appropriate type
§Returns
A Result containing either the parsed AttrOption or an error if parsing fails
Sourcepub fn to_pair(&self) -> (String, String)
pub fn to_pair(&self) -> (String, String)
Converts the option into a key-value pair.
§Returns
A tuple containing the option’s key and value as strings
Trait Implementations§
Source§impl Clone for AttrOption
impl Clone for AttrOption
Source§fn clone(&self) -> AttrOption
fn clone(&self) -> AttrOption
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AttrOption
impl Debug for AttrOption
Source§impl<'de> Deserialize<'de> for AttrOption
impl<'de> Deserialize<'de> for AttrOption
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 Display for AttrOption
impl Display for AttrOption
Source§impl From<AttrOption> for RawOption
impl From<AttrOption> for RawOption
Source§fn from(option: AttrOption) -> Self
fn from(option: AttrOption) -> Self
Source§impl FromStr for AttrOption
impl FromStr for AttrOption
Source§impl PartialEq for AttrOption
impl PartialEq for AttrOption
Source§fn eq(&self, other: &AttrOption) -> bool
fn eq(&self, other: &AttrOption) -> bool
self and other values to be equal, and is used by ==.