Skip to main content

ferroui_base/diagnostics/
ferro_property_value.rs

1//! Port of `Diagnostics/FerroPropertyValue.cs`.
2
3use crate::data::BindingPriority;
4use crate::{BoxedValue, FerroProperty};
5
6/// Holds diagnostic-related information about the value of a
7/// [`FerroProperty`] on a [`FerroObject`](crate::FerroObject).
8#[derive(Clone)]
9pub struct FerroPropertyValue {
10    property: &'static FerroProperty,
11    value: BoxedValue,
12    priority: BindingPriority,
13    diagnostic: Option<String>,
14    is_overridden_current_value: bool,
15}
16
17impl FerroPropertyValue {
18    pub(crate) fn new(
19        property: &'static FerroProperty,
20        value: BoxedValue,
21        priority: BindingPriority,
22        diagnostic: Option<String>,
23        is_overridden_current_value: bool,
24    ) -> Self {
25        Self { property, value, priority, diagnostic, is_overridden_current_value }
26    }
27
28    /// Gets the property.
29    pub fn property(&self) -> &'static FerroProperty {
30        self.property
31    }
32
33    /// Gets the current property value: a value of the type of the property.
34    pub fn value(&self) -> &BoxedValue {
35        &self.value
36    }
37
38    /// Gets the priority of the current value.
39    pub fn priority(&self) -> BindingPriority {
40        self.priority
41    }
42
43    /// Gets a diagnostic string.
44    pub fn diagnostic(&self) -> Option<&str> {
45        self.diagnostic.as_deref()
46    }
47
48    /// Gets a value indicating whether the [`value`](Self::value) was
49    /// overridden by a call to
50    /// [`FerroObject::set_current_value`](crate::FerroObject::set_current_value).
51    pub fn is_overridden_current_value(&self) -> bool {
52        self.is_overridden_current_value
53    }
54}