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§
Sourcefn logical_name(&self) -> &ObisCode
fn logical_name(&self) -> &ObisCode
Returns the object’s logical name (OBIS code).
Sourcefn attributes(&self) -> Vec<(u8, CosemDataType)>
fn attributes(&self) -> Vec<(u8, CosemDataType)>
Returns the class attributes as (attribute_id, value) pairs.
Sourcefn invoke_method(
&mut self,
method_id: u8,
params: Option<CosemDataType>,
) -> Result<CosemDataType, String>
fn invoke_method( &mut self, method_id: u8, params: Option<CosemDataType>, ) -> Result<CosemDataType, String>
Provided Methods§
Sourcefn set_attribute(
&mut self,
attribute_id: u8,
value: CosemDataType,
) -> Result<(), String>
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".