pub struct TypedDataPoint<T>where
T: DataPointType,{
pub id: String,
pub name: String,
pub description: String,
pub access: AccessMode,
pub units: Option<String>,
pub min_value: Option<f64>,
pub max_value: Option<f64>,
pub default_value: Option<T>,
/* private fields */
}Expand description
A type-safe data point reference.
This struct wraps a data point with compile-time type information, ensuring type safety when reading and writing values.
Fields§
§id: StringPoint ID within the device.
name: StringHuman-readable name.
description: StringDescription.
access: AccessModeAccess mode.
units: Option<String>Engineering units.
min_value: Option<f64>Minimum value (for numeric types).
max_value: Option<f64>Maximum value (for numeric types).
default_value: Option<T>Default value.
Implementations§
Source§impl<T> TypedDataPoint<T>where
T: DataPointType,
impl<T> TypedDataPoint<T>where
T: DataPointType,
Sourcepub fn new(id: impl Into<String>, name: impl Into<String>) -> TypedDataPoint<T>
pub fn new(id: impl Into<String>, name: impl Into<String>) -> TypedDataPoint<T>
Create a new typed data point.
Sourcepub fn with_description(
self,
description: impl Into<String>,
) -> TypedDataPoint<T>
pub fn with_description( self, description: impl Into<String>, ) -> TypedDataPoint<T>
Set the description.
Sourcepub fn with_access(self, access: AccessMode) -> TypedDataPoint<T>
pub fn with_access(self, access: AccessMode) -> TypedDataPoint<T>
Set the access mode.
Sourcepub fn read_only(self) -> TypedDataPoint<T>
pub fn read_only(self) -> TypedDataPoint<T>
Set as read-only.
Sourcepub fn write_only(self) -> TypedDataPoint<T>
pub fn write_only(self) -> TypedDataPoint<T>
Set as write-only.
Sourcepub fn with_units(self, units: impl Into<String>) -> TypedDataPoint<T>
pub fn with_units(self, units: impl Into<String>) -> TypedDataPoint<T>
Set the engineering units.
Sourcepub fn with_range(self, min: f64, max: f64) -> TypedDataPoint<T>
pub fn with_range(self, min: f64, max: f64) -> TypedDataPoint<T>
Set the value range.
Sourcepub fn with_default(self, value: T) -> TypedDataPoint<T>
pub fn with_default(self, value: T) -> TypedDataPoint<T>
Set the default value.
Sourcepub fn to_definition(&self) -> DataPointDef
pub fn to_definition(&self) -> DataPointDef
Convert to an untyped DataPointDef.
Sourcepub fn validate_range(&self, value: f64) -> Result<(), Error>
pub fn validate_range(&self, value: f64) -> Result<(), Error>
Check if a value is within the valid range.
Sourcepub fn convert_value(&self, value: &Value) -> Result<T, Error>
pub fn convert_value(&self, value: &Value) -> Result<T, Error>
Convert a Value to this point’s type with validation.
Sourcepub fn id_for_device(&self, device_id: &str) -> DataPointId
pub fn id_for_device(&self, device_id: &str) -> DataPointId
Create a DataPointId for a given device.
Trait Implementations§
Source§impl<T> Clone for TypedDataPoint<T>where
T: Clone + DataPointType,
impl<T> Clone for TypedDataPoint<T>where
T: Clone + DataPointType,
Source§fn clone(&self) -> TypedDataPoint<T>
fn clone(&self) -> TypedDataPoint<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T> Debug for TypedDataPoint<T>where
T: Debug + DataPointType,
impl<T> Debug for TypedDataPoint<T>where
T: Debug + DataPointType,
Source§impl<T> FromDefinition for TypedDataPoint<T>where
T: DataPointType,
impl<T> FromDefinition for TypedDataPoint<T>where
T: DataPointType,
Source§fn from_definition(def: &DataPointDef) -> Result<TypedDataPoint<T>, Error>
fn from_definition(def: &DataPointDef) -> Result<TypedDataPoint<T>, Error>
Try to create a typed point from a definition.
Auto Trait Implementations§
impl<T> Freeze for TypedDataPoint<T>where
T: Freeze,
impl<T> RefUnwindSafe for TypedDataPoint<T>where
T: RefUnwindSafe,
impl<T> Send for TypedDataPoint<T>
impl<T> Sync for TypedDataPoint<T>
impl<T> Unpin for TypedDataPoint<T>where
T: Unpin,
impl<T> UnsafeUnpin for TypedDataPoint<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for TypedDataPoint<T>where
T: UnwindSafe,
Blanket Implementations§
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<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