righvalor 0.1.0

RighValor: AI Infrastructure and Applications Framework for the Far Edge
//! Service entity abstractions for the Valor system.
//!
//! This module defines the core trait that all Valor service entities must implement.
//! Service entities represent individual services or components within the Valor
//! distributed system, providing standardized access to their identity, runtime,
//! and metadata.

use righ_dm_rs::RighVersion;

use crate::{runtime::ValorRuntimeEngine, service::ValorServiceId};

/// A trait defining the core interface for all Valor service entities.
///
/// This trait provides a standardized way to interact with different types of
/// services within the Valor ecosystem. Each service entity has a service identity,
/// node identity, runtime environment, version information, and associated metadata.
///
/// # Examples
///
/// ```rust
/// use valor::service::entity::ValorServiceEntity;
/// use valor::service::ValorServiceId;
/// use righ_dm_rs::RighVersion;
/// use valor::runtime::ValorRuntimeEngine;
///
/// struct MyService {
///     service_id: ValorServiceId,
///     runtime: ValorRuntimeEngine,
///     version: RighVersion,
///     metadata: Vec<u8>,
/// }
///
/// impl ValorServiceEntity for MyService {
///     fn service_id(&self) -> ValorServiceId {
///         self.service_id.clone()
///     }
///
///     fn runtime(&self) -> ValorRuntimeEngine {
///         self.runtime.clone()
///     }
///
///     fn version(&self) -> RighVersion {
///         self.version.clone()
///     }
///
///     fn metadata(&self) -> Option<&[u8]> {
///         Some(&self.metadata)
///     }
///
///     fn model_path(&self) -> Option<&std::path::PathBuf> {
///         None
///     }
/// }
/// ```
#[allow(unused)]
pub trait ValorServiceEntity {
    /// Returns the service identifier for this service entity.
    ///
    /// The service ID identifies the type of service (e.g., "righ.device_classification"),
    /// distinguishing it from other service types in the registry.
    ///
    /// # Returns
    ///
    /// A `ValorServiceId` representing the service type identifier.
    fn service_id(&self) -> ValorServiceId;

    /// Returns the runtime engine associated with this service entity.
    ///
    /// The runtime engine manages the execution environment and lifecycle
    /// of the service entity within the Valor system.
    ///
    /// # Returns
    ///
    /// A `ValorRuntimeEngine` instance managing this service entity.
    fn runtime(&self) -> ValorRuntimeEngine;

    /// Returns the version information for this service entity.
    ///
    /// Version information is crucial for compatibility checking, updates,
    /// and maintaining service interoperability within the distributed system.
    ///
    /// # Returns
    ///
    /// A `RighVersion` representing the current version of this service entity.
    fn version(&self) -> RighVersion;

    /// Returns the metadata associated with this service entity.
    ///
    /// Metadata contains additional information about the service entity,
    /// such as configuration data, capabilities, or other service-specific
    /// information encoded as bytes.
    ///
    /// # Returns
    ///
    /// A byte slice containing the metadata for this service entity.
    fn metadata(&self) -> Option<&[u8]>;

    /// Returns the model path for this service entity.
    ///
    /// The model path is the filesystem path to the model file for this service entity.
    ///
    /// # Returns
    ///
    /// An `Option<&std::path::PathBuf>` containing the model path for this service entity, or `None` if not applicable.
    fn model_path(&self) -> Option<&std::path::PathBuf>;
}