pub struct Component {
pub name: ValidName,
pub amount: ValidAmount,
pub scores: Vec<Score>,
}Expand description
A Component represents a single component that is to be accounted for.
A component has an associated name and amount (how many or how much of this component is to
be accounted for).
Optionally, multiple Scores can be attached to a single component.
§Example:
Create a component that represents 10 CPU cores with a HEPSPEC06 value of 9.2.
let component = Component::new("CPU", 10)?
.with_score(Score::new("HEPSPEC06", 9.2)?);Fields§
§name: ValidNameName of the component.
amount: ValidAmountAmount of the component (how many or how much of this component is to be accounted for).
scores: Vec<Score>Scores that are attached to the component.
Implementations§
Source§impl Component
impl Component
Sourcepub fn new<T: AsRef<str>>(name: T, amount: i64) -> Result<Self, Error>
pub fn new<T: AsRef<str>>(name: T, amount: i64) -> Result<Self, Error>
Create a new component.
§Errors
anyhow::Error- If there was an invalid character (/()"<>\{}) in thenameor if a negativeamountwas given.
Sourcepub fn with_score(self, score: Score) -> Self
pub fn with_score(self, score: Score) -> Self
Attach a Score to the component.
Sourcepub fn with_scores(self, scores: Vec<Score>) -> Self
pub fn with_scores(self, scores: Vec<Score>) -> Self
Attach multiple Scores to the component.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Component
impl<'de> Deserialize<'de> for Component
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<'q> Encode<'_, Postgres> for Component
impl<'q> Encode<'_, Postgres> for Component
Source§fn encode_by_ref(
&self,
buf: &mut PgArgumentBuffer,
) -> Result<IsNull, BoxDynError>
fn encode_by_ref( &self, buf: &mut PgArgumentBuffer, ) -> Result<IsNull, BoxDynError>
fn size_hint(&self) -> usize
Source§fn encode(
self,
buf: &mut <DB as Database>::ArgumentBuffer<'q>,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>where
Self: Sized,
fn encode(
self,
buf: &mut <DB as Database>::ArgumentBuffer<'q>,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>where
Self: Sized,
Writes the value of
self into buf in the expected format for the database.fn produces(&self) -> Option<<DB as Database>::TypeInfo>
Source§impl Ord for Component
impl Ord for Component
Source§impl PartialEq<Component> for ComponentTest
impl PartialEq<Component> for ComponentTest
Source§impl PartialEq<ComponentTest> for Component
impl PartialEq<ComponentTest> for Component
Source§impl PartialOrd for Component
impl PartialOrd for Component
Source§impl PgHasArrayType for Component
impl PgHasArrayType for Component
fn array_type_info() -> PgTypeInfo
fn array_compatible(ty: &PgTypeInfo) -> bool
Source§impl TryFrom<ComponentTest> for Component
impl TryFrom<ComponentTest> for Component
impl Eq for Component
impl StructuralPartialEq for Component
Auto Trait Implementations§
impl Freeze for Component
impl RefUnwindSafe for Component
impl Send for Component
impl Sync for Component
impl Unpin for Component
impl UnwindSafe for Component
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more