Skip to main content

InterfaceClass

Trait InterfaceClass 

Source
pub trait InterfaceClass: Any {
    // Required methods
    fn class_id(&self) -> u16;
    fn version(&self) -> u8;
    fn logical_name(&self) -> &ObisCode;
    fn attributes(&self) -> Vec<(u8, CosemDataType)>;
    fn methods(&self) -> Vec<(u8, String)>;
    fn serialize_ber(&self, buf: &mut Vec<u8>) -> Result<(), BerError>;
    fn deserialize_ber(&mut self, data: &[u8]) -> Result<(), BerError>;
    fn invoke_method(
        &mut self,
        method_id: u8,
        params: Option<CosemDataType>,
    ) -> Result<CosemDataType, String>;
    fn as_any(&self) -> &dyn Any;

    // Provided method
    fn set_attribute(
        &mut self,
        attribute_id: u8,
        value: CosemDataType,
    ) -> Result<(), String> { ... }
}
Expand description

The trait shared by every COSEM interface class defined in IEC 62056-6-2.

Each class exposes its class id, version, logical name (OBIS code), attributes and methods, and supports BER serialization/deserialization and method invocation.

Required Methods§

Source

fn class_id(&self) -> u16

Returns the class id (class_id) as defined in IEC 62056-6-2.

Source

fn version(&self) -> u8

Returns the class version.

Source

fn logical_name(&self) -> &ObisCode

Returns the object’s logical name (OBIS code).

Source

fn attributes(&self) -> Vec<(u8, CosemDataType)>

Returns the class attributes as (attribute_id, value) pairs.

Source

fn methods(&self) -> Vec<(u8, String)>

Returns the class methods as (method_id, name) pairs.

Source

fn serialize_ber(&self, buf: &mut Vec<u8>) -> Result<(), BerError>

Serializes the object into BER.

§Arguments
  • buf - The buffer the serialized bytes are appended to.
§Returns
  • Ok(()) - On success.
  • Err(BerError) - On a serialization error.
Source

fn deserialize_ber(&mut self, data: &[u8]) -> Result<(), BerError>

Deserializes the object from BER data.

§Arguments
  • data - The input BER bytes.
§Returns
  • Ok(()) - On success.
  • Err(BerError) - On a deserialization error.
Source

fn invoke_method( &mut self, method_id: u8, params: Option<CosemDataType>, ) -> Result<CosemDataType, String>

Invokes the object method with the given id.

§Arguments
  • method_id - The method id.
  • params - Optional method parameters as a CosemDataType.
§Returns
  • Ok(CosemDataType) - The method result.
  • Err(String) - An error description if the method is not supported.
Source

fn as_any(&self) -> &dyn Any

Returns the object as dyn Any for dynamic downcasting.

Provided Methods§

Source

fn set_attribute( &mut self, attribute_id: u8, value: CosemDataType, ) -> Result<(), String>

Writes the value of a writable attribute. The default implementation rejects the write; classes with writable attributes override it.

§Arguments
  • attribute_id - The attribute to write.
  • value - The new attribute value.
§Returns
  • Ok(()) - If the attribute was written.
  • Err(String) - If the attribute is not writable or the value is invalid.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl InterfaceClass for ActivityCalendar

Source§

impl InterfaceClass for Arbitrator

Source§

impl InterfaceClass for AssociationLn

Source§

impl InterfaceClass for Clock

Source§

impl InterfaceClass for CompactData

Source§

impl InterfaceClass for Data

Source§

impl InterfaceClass for DataProtection

Source§

impl InterfaceClass for DemandRegister

Source§

impl InterfaceClass for DisconnectControl

Source§

impl InterfaceClass for ExtendedRegister

Source§

impl InterfaceClass for GprsModemSetup

Source§

impl InterfaceClass for GsmDiagnostic

Source§

impl InterfaceClass for IecHdlcSetup

Source§

impl InterfaceClass for IecLocalPortSetup

Source§

impl InterfaceClass for ImageTransfer

Source§

impl InterfaceClass for Ipv4Setup

Source§

impl InterfaceClass for Ipv6Setup

Source§

impl InterfaceClass for Limiter

Source§

impl InterfaceClass for MacAddressSetup

Source§

impl InterfaceClass for MbusSlave

Source§

impl InterfaceClass for MbusSlavePortSetup

Source§

impl InterfaceClass for ParameterMonitor

Source§

impl InterfaceClass for ProfileDataFilter

Source§

impl InterfaceClass for ProfileGeneric

Source§

impl InterfaceClass for PushSetup

Source§

impl InterfaceClass for Register

Source§

impl InterfaceClass for RegisterActivation

Source§

impl InterfaceClass for RegisterMonitor

Source§

impl InterfaceClass for RegisterTable

Source§

impl InterfaceClass for SapAssignment

Source§

impl InterfaceClass for Schedule

Source§

impl InterfaceClass for ScriptTable

Source§

impl InterfaceClass for SecuritySetup

Source§

impl InterfaceClass for SingleActionSchedule

Source§

impl InterfaceClass for SpecialDaysTable

Source§

impl InterfaceClass for StatusMapping

Source§

impl InterfaceClass for TableManager

Source§

impl InterfaceClass for TcpUdpSetup

Source§

impl InterfaceClass for UtilityTables