Use tag introspection to discover a tag’s type, size, dimensions, and scope before reading or writing. This is useful for:
- Validating tag names and types at startup
- Building generic tools that work with any tag
- Handling arrays and UDTs when you don’t have a fixed schema
let attrs = client.get_tag_attributes("MyTag").await?;TagAttributes includes:
| Field | Description |
|---|---|
name |
Tag name as returned by the PLC |
data_type |
CIP type code (e.g. 0xC4 for DINT) |
data_type_name |
Human-readable type (e.g. "DINT") |
dimensions |
Array dimensions; empty for scalars |
permissions |
ReadOnly, ReadWrite, or WriteOnly |
scope |
Controller or Program(name) |
size |
Size in bytes |
template_instance_id |
Set for UDTs (for template discovery) |
use rust_ethernet_ip::{EipClient, PlcValue};
let attrs = client.get_tag_attributes("ProductionCount").await?;
println!("Type: {}, size: {} bytes", attrs.data_type_name, attrs.size);
let value = client.read_tag("ProductionCount").await?;
match value {
PlcValue::Dint(n) => println!("Count: {}", n),
_ => println!("Unexpected type"),
}let attrs = client.get_tag_attributes("LineData").await?;
if attrs.dimensions.is_empty() {
println!("Scalar tag");
} else {
println!("Array dimensions: {:?}", attrs.dimensions);
}Attributes are cached per tag for the lifetime of the EipClient. The first call for a given tag name performs a CIP Get Attribute List request; subsequent calls for the same tag return the cached result.
get_udt_definitionfor full UDT member layoutdiscover_tagsto list controller tags