Skip to main content

Param

Struct Param 

Source
pub struct Param {
    pub name: String,
    pub value: Value,
    pub accession: Option<AccessionIntCode>,
    pub controlled_vocabulary: Option<ControlledVocabulary>,
    pub unit: Unit,
}
Expand description

A controlled vocabulary or user parameter

Fields§

§name: String

The human-readable name of the parameter.

§value: Value

A type generic value associated with the parameter

§accession: Option<AccessionIntCode>

The numeric component of the accession code in the identifier for the parameter’s definition in Self::controlled_vocabulary, if it is defined by one.

§controlled_vocabulary: Option<ControlledVocabulary>

The controlled vocabulary this parameter is defined in, if any.

§unit: Unit

The unit the parameter’s value is expressed in, if any.

Implementations§

Source§

impl Param

Source

pub fn new() -> Param

Source

pub fn builder() -> ParamBuilder

Create a new ParamBuilder to make creating a new Param more convenient than setting fields on a bare Param directly.

Source

pub fn new_key_value<K: Into<String>, V: Into<Value>>( name: K, value: V, ) -> Param

A construction method for Param that sets Param::name and Param::value but leaves all other attributes as default.

Source

pub fn parse<T: FromStr>(&self) -> Result<T, T::Err>

Attempt to parse the value of this parameter into T.

See Value::parse

Source

pub const fn is_controlled(&self) -> bool

Check if this parameter is defined in a controlled vocabulary

Source

pub const fn curie(&self) -> Option<CURIE>

Source

pub fn curie_str(&self) -> Option<String>

Format the Param::curie as a string, if it exists

Source

pub fn with_unit<S: AsRef<str>, A: AsRef<str>>( self, accession: S, name: A, ) -> Param

Update Param::unit inferred from accession, failing that, name

§See also
Source

pub fn with_unit_t(self, unit: &Unit) -> Param

Set Param::unit directly from unit.

§See also

Trait Implementations§

Source§

impl AsRef<Value> for Param

Source§

fn as_ref(&self) -> &Value

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for Param

Source§

fn clone(&self) -> Param

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Param

Source§

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

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

impl Default for Param

Source§

fn default() -> Param

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

impl Display for Param

Source§

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

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

impl Eq for Param

Source§

impl<'a> From<ParamCow<'a>> for Param

Source§

fn from(value: ParamCow<'a>) -> Self

Converts to this type from the input type.
Source§

impl Hash for Param

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl ParamLike for Param

Source§

fn name(&self) -> &str

The human-readable name of the parameter.
Source§

fn value(&self) -> ValueRef<'_>

A borrowed view of the parameter’s value.
Source§

fn accession(&self) -> Option<AccessionIntCode>

The numeric accession code within ParamLike::controlled_vocabulary, if this parameter is drawn from a controlled vocabulary.
Source§

fn controlled_vocabulary(&self) -> Option<ControlledVocabulary>

The controlled vocabulary this parameter’s term belongs to, if any.
Source§

fn unit(&self) -> Unit

The unit the parameter’s value is expressed in, if known.
Source§

fn is_ms(&self) -> bool

Check whether this parameter’s term belongs to the PSI-MS controlled vocabulary.
Source§

fn parse<T: FromStr>(&self) -> Result<T, T::Err>

Parse the parameter’s value as T. See ParamValue::parse.
Source§

fn is_controlled(&self) -> bool

Check whether this parameter is drawn from a controlled vocabulary, as opposed to being a free-text user-defined parameter.
Source§

fn curie(&self) -> Option<CURIE>

Build a CURIE from ParamLike::controlled_vocabulary and ParamLike::accession, if both are present.
Source§

impl ParamValue for Param

Source§

fn is_empty(&self) -> bool

Check if the value is empty
Source§

fn is_i64(&self) -> bool

Check if the value is an integer
Source§

fn is_f64(&self) -> bool

Check if the value is a floating point number explicitly. An integral number might still be usable as a floating point number
Source§

fn is_buffer(&self) -> bool

Check if the value is an arbitrary buffer
Source§

fn is_str(&self) -> bool

Check if the value is stored as an explicit string. All variants can be coerced to a string.
Source§

fn to_f64(&self) -> Result<f64, ParamValueParseError>

Get the value as an f64, if possible
Source§

fn to_i64(&self) -> Result<i64, ParamValueParseError>

Get the value as an i64, if possible
Source§

fn to_str(&self) -> Cow<'_, str>

Get the value as a string
Source§

fn to_buffer(&self) -> Result<Cow<'_, [u8]>, ParamValueParseError>

Get the value as a byte buffer, if possible. Read more
Source§

fn parse<T: FromStr>(&self) -> Result<T, T::Err>

Convert the value’s string representation to T if possible
Source§

fn as_bytes(&self) -> Cow<'_, [u8]>

Convert the value to a byte string, the bytes of the string representation.
Source§

fn as_ref(&self) -> ValueRef<'_>

Get a reference to the stored value
Source§

fn data_len(&self) -> usize

Get the size of the stored data type
Source§

fn is_boolean(&self) -> bool

Check if the value is a boolean
Source§

fn to_bool(&self) -> Result<bool, ParamValueParseError>

Get the value as a bool, if possible
Source§

fn is_list(&self) -> bool

Check if the value is a list
Source§

fn as_slice(&self) -> Cow<'_, [Value]>

Get the value as a slice
Source§

fn is_numeric(&self) -> bool

Check if the value is of either numeric type.
Source§

fn to_f32(&self) -> Result<f32, ParamValueParseError>

Get the value as an f32, if possible
Source§

fn to_i32(&self) -> Result<i32, ParamValueParseError>

Get the value as an i32, if possible
Source§

fn to_u64(&self) -> Result<u64, ParamValueParseError>

Get the value as an u64, if possible
Source§

fn as_str(&self) -> Cow<'_, str>

Get the value as a string, possibly borrowed
Source§

impl PartialEq for Param

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl PartialEq<CURIE> for Param

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl PartialEq<Param> for ParamCow<'_>

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<'a> PartialEq<ParamCow<'a>> for Param

Source§

fn eq(&self, other: &ParamCow<'a>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Param

Source§

impl TryFrom<&Param> for CURIE

Source§

type Error = String

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

fn try_from(value: &Param) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl Freeze for Param

§

impl RefUnwindSafe for Param

§

impl Send for Param

§

impl Sync for Param

§

impl Unpin for Param

§

impl UnsafeUnpin for Param

§

impl UnwindSafe for Param

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, 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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.