pub struct DMSCDevice { /* private fields */ }Expand description
Smart device representation
This struct represents a smart device in the DMSC system, including its status, capabilities, health metrics, and lifecycle information.
Implementations§
Source§impl DMSCDevice
impl DMSCDevice
Sourcepub fn new(name: String, device_type: DMSCDeviceType) -> Self
pub fn new(name: String, device_type: DMSCDeviceType) -> Self
Sourcepub fn device_type(&self) -> DMSCDeviceType
pub fn device_type(&self) -> DMSCDeviceType
Sourcepub fn status(&self) -> DMSCDeviceStatus
pub fn status(&self) -> DMSCDeviceStatus
Sourcepub fn capabilities(&self) -> &DMSCDeviceCapabilities
pub fn capabilities(&self) -> &DMSCDeviceCapabilities
Gets a reference to the device capabilities
§Returns
A reference to the DMSCDeviceCapabilities structure
Sourcepub fn health_metrics(&self) -> &DMSCDeviceHealthMetrics
pub fn health_metrics(&self) -> &DMSCDeviceHealthMetrics
Gets a reference to the device health metrics
§Returns
A reference to the DMSCDeviceHealthMetrics structure
Sourcepub fn set_status(&mut self, status: DMSCDeviceStatus)
pub fn set_status(&mut self, status: DMSCDeviceStatus)
Sets the device status and updates the last seen timestamp
§Parameters
status: The new status to set
Sourcepub fn update_health_metrics(&mut self, metrics: DMSCDeviceHealthMetrics)
pub fn update_health_metrics(&mut self, metrics: DMSCDeviceHealthMetrics)
Updates the device health metrics and last seen timestamp
§Parameters
metrics: The new health metrics to set
Sourcepub fn increment_error_count(&mut self)
pub fn increment_error_count(&mut self)
Increments the device error count and updates the last seen timestamp
Sourcepub fn update_throughput(&mut self, throughput: u64)
pub fn update_throughput(&mut self, throughput: u64)
Updates the device throughput and last seen timestamp
§Parameters
throughput: The new throughput value in operations per second
Sourcepub fn with_capabilities(self, capabilities: DMSCDeviceCapabilities) -> Self
pub fn with_capabilities(self, capabilities: DMSCDeviceCapabilities) -> Self
Sourcepub fn set_location(&mut self, location: String)
pub fn set_location(&mut self, location: String)
Sourcepub fn add_metadata(&mut self, key: String, value: String)
pub fn add_metadata(&mut self, key: String, value: String)
Sourcepub fn update_last_seen(&mut self)
pub fn update_last_seen(&mut self)
Updates the last seen timestamp to the current time
Sourcepub fn is_available(&self) -> bool
pub fn is_available(&self) -> bool
Checks if the device is available for allocation
A device is available if its status is Available and it has no current allocation.
§Returns
true if the device is available, false otherwise
Sourcepub fn is_allocated(&self) -> bool
pub fn is_allocated(&self) -> bool
Checks if the device is currently allocated
§Returns
true if the device is allocated, false otherwise
Sourcepub fn release(&mut self)
pub fn release(&mut self)
Releases the device from its current allocation
This method clears the allocation ID and sets the device status to Available if it was Busy.
Sourcepub fn remove_tag(&mut self, tag: &str) -> bool
pub fn remove_tag(&mut self, tag: &str) -> bool
Sourcepub fn get_allocation_id(&self) -> Option<&str>
pub fn get_allocation_id(&self) -> Option<&str>
Gets the current allocation ID if the device is allocated
§Returns
An Option<&str> containing the allocation ID if the device is allocated, None otherwise
Sourcepub fn health_score(&self) -> u8
pub fn health_score(&self) -> u8
Calculates a simple health score based on device status (0-100)
This method returns a basic health score based solely on the device status.
§Returns
A health score between 0 (worst) and 100 (best)
Sourcepub fn is_responsive(&self, timeout_secs: i64) -> bool
pub fn is_responsive(&self, timeout_secs: i64) -> bool
Sourcepub fn dynamic_health_score(
&self,
health_metrics: &DMSCDeviceHealthMetrics,
) -> u8
pub fn dynamic_health_score( &self, health_metrics: &DMSCDeviceHealthMetrics, ) -> u8
Calculates a dynamic health score based on multiple factors (0-100)
This method calculates a comprehensive health score based on device status, CPU usage, memory usage, temperature, and error count.
§Parameters
health_metrics: Current health metrics for the device
§Returns
A dynamic health score between 0 (worst) and 100 (best)
Sourcepub fn is_healthy(
&self,
health_metrics: &DMSCDeviceHealthMetrics,
timeout_secs: i64,
) -> bool
pub fn is_healthy( &self, health_metrics: &DMSCDeviceHealthMetrics, timeout_secs: i64, ) -> bool
Checks if the device is healthy based on multiple criteria
A device is considered healthy if it is responsive, has a good health score, and is not in an error or offline state.
§Parameters
health_metrics: Current health metrics for the devicetimeout_secs: Maximum number of seconds since last seen for the device to be considered responsive
§Returns
true if the device is healthy, false otherwise
Trait Implementations§
Source§impl Clone for DMSCDevice
impl Clone for DMSCDevice
Source§fn clone(&self) -> DMSCDevice
fn clone(&self) -> DMSCDevice
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DMSCDevice
impl Debug for DMSCDevice
Source§impl<'de> Deserialize<'de> for DMSCDevice
impl<'de> Deserialize<'de> for DMSCDevice
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<'py> IntoPyObject<'py> for DMSCDevice
impl<'py> IntoPyObject<'py> for DMSCDevice
Source§type Target = DMSCDevice
type Target = DMSCDevice
Source§type Output = Bound<'py, <DMSCDevice as IntoPyObject<'py>>::Target>
type Output = Bound<'py, <DMSCDevice as IntoPyObject<'py>>::Target>
Source§fn into_pyobject(
self,
py: Python<'py>,
) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
fn into_pyobject( self, py: Python<'py>, ) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
Source§impl PyClass for DMSCDevice
impl PyClass for DMSCDevice
Source§impl PyClassImpl for DMSCDevice
impl PyClassImpl for DMSCDevice
Source§const IS_BASETYPE: bool = false
const IS_BASETYPE: bool = false
Source§const IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
Source§const IS_MAPPING: bool = false
const IS_MAPPING: bool = false
Source§const IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
Source§const IS_IMMUTABLE_TYPE: bool = false
const IS_IMMUTABLE_TYPE: bool = false
Source§const RAW_DOC: &'static CStr = c"Smart device representation\n\nThis struct represents a smart device in the DMSC system, including its status, capabilities,\nhealth metrics, and lifecycle information.\x00"
const RAW_DOC: &'static CStr = c"Smart device representation\n\nThis struct represents a smart device in the DMSC system, including its status, capabilities,\nhealth metrics, and lifecycle information.\x00"
Source§const DOC: &'static CStr
const DOC: &'static CStr
text_signature if a constructor is defined. Read moreSource§type ThreadChecker = SendablePyClass<DMSCDevice>
type ThreadChecker = SendablePyClass<DMSCDevice>
Source§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
Source§type BaseNativeType = PyAny
type BaseNativeType = PyAny
PyAny by default, and when you declare
#[pyclass(extends=PyDict)], it’s PyDict.fn items_iter() -> PyClassItemsIter
fn lazy_type_object() -> &'static LazyTypeObject<Self>
fn dict_offset() -> Option<isize>
fn weaklist_offset() -> Option<isize>
Source§impl PyClassNewTextSignature for DMSCDevice
impl PyClassNewTextSignature for DMSCDevice
const TEXT_SIGNATURE: &'static str = "(name, device_type)"
Source§impl PyMethods<DMSCDevice> for PyClassImplCollector<DMSCDevice>
impl PyMethods<DMSCDevice> for PyClassImplCollector<DMSCDevice>
fn py_methods(self) -> &'static PyClassItems
Source§impl PyTypeInfo for DMSCDevice
impl PyTypeInfo for DMSCDevice
Source§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
§fn type_object(py: Python<'_>) -> Bound<'_, PyType>
fn type_object(py: Python<'_>) -> Bound<'_, PyType>
§fn is_type_of(object: &Bound<'_, PyAny>) -> bool
fn is_type_of(object: &Bound<'_, PyAny>) -> bool
object is an instance of this type or a subclass of this type.§fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool
fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool
object is an instance of this type.Source§impl Serialize for DMSCDevice
impl Serialize for DMSCDevice
impl DerefToPyAny for DMSCDevice
impl ExtractPyClassWithClone for DMSCDevice
Auto Trait Implementations§
impl Freeze for DMSCDevice
impl RefUnwindSafe for DMSCDevice
impl Send for DMSCDevice
impl Sync for DMSCDevice
impl Unpin for DMSCDevice
impl UnwindSafe for DMSCDevice
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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>
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§impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
§fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
self into an owned Python object, dropping type information.§fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>
fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>
self into an owned Python object, dropping type information and unbinding it
from the 'py lifetime.§fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>
fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>
self into a Python object. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PyErrArguments for T
impl<T> PyErrArguments for T
§impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
§const NAME: &'static str = T::NAME
const NAME: &'static str = T::NAME
§fn type_check(object: &Bound<'_, PyAny>) -> bool
fn type_check(object: &Bound<'_, PyAny>) -> bool
§fn classinfo_object(py: Python<'_>) -> Bound<'_, PyAny>
fn classinfo_object(py: Python<'_>) -> Bound<'_, PyAny>
isinstance and issubclass function. Read more