pub struct UdmEvent {Show 32 fields
pub event_id: String,
pub captured_at: DateTime<Utc>,
pub event_type: EventType,
pub source_id: String,
pub source_type: SourceType,
pub udm_version: String,
pub sdk_version: String,
pub identity: Option<IdentityDomain>,
pub location: Option<LocationDomain>,
pub motion: Option<MotionDomain>,
pub power: Option<PowerDomain>,
pub operational: Option<OperationalDomain>,
pub navigation: Option<NavigationDomain>,
pub perception: Option<PerceptionDomain>,
pub safety: Option<SafetyDomain>,
pub actuators: Option<ActuatorsDomain>,
pub communication: Option<CommunicationDomain>,
pub compute: Option<ComputeDomain>,
pub ai: Option<AiDomain>,
pub maintenance: Option<MaintenanceDomain>,
pub context: Option<ContextDomain>,
pub payload: Option<PayloadDomain>,
pub manipulation: Option<ManipulationDomain>,
pub hri: Option<HriDomain>,
pub coordination: Option<CoordinationDomain>,
pub simulation: Option<SimulationDomain>,
pub thermal: Option<ThermalDomain>,
pub audio: Option<AudioDomain>,
pub environment_interaction: Option<EnvironmentInteractionDomain>,
pub compliance: Option<ComplianceDomain>,
pub provenance: Option<Provenance>,
pub extensions: Option<Value>,
}Expand description
UDM Event - The unified data model event envelope.
This is the primary structure emitted by the PhyTrace SDK. It contains:
- Required envelope fields (event_id, timestamp, source_type)
- Optional domain data for all 23 UDM domains
- Provenance information for data integrity verification
- Extension point for custom data
§Example
use phytrace_sdk::{UdmEvent, EventType, SourceType};
use phytrace_sdk::models::domains::{IdentityDomain, LocationDomain};
use phytrace_sdk::models::domains::location::LocalCoordinates;
let event = UdmEvent::new(SourceType::Amr)
.with_event_type(EventType::TelemetryPeriodic)
.with_identity(IdentityDomain {
source_id: Some("robot-001".to_string()),
..Default::default()
})
.with_location(LocationDomain {
local: Some(LocalCoordinates {
x_m: Some(10.0),
y_m: Some(20.0),
..Default::default()
}),
..Default::default()
});Fields§
§event_id: StringUnique event identifier (UUIDv7 for time-ordering).
captured_at: DateTime<Utc>When data was captured at source (ISO 8601 format). Note: This matches PhyCloud’s expected field name.
event_type: EventTypeType of event.
source_id: StringUnique source identifier (e.g., robot-001). This is a required top-level field for PhyCloud compatibility.
source_type: SourceTypeType of source generating this event.
udm_version: StringUDM schema version.
sdk_version: StringSDK version that generated this event.
identity: Option<IdentityDomain>Identity domain - who/what is reporting.
location: Option<LocationDomain>Location domain - where the source is.
motion: Option<MotionDomain>Motion domain - velocity, acceleration, odometry.
power: Option<PowerDomain>Power domain - battery, charging, energy.
operational: Option<OperationalDomain>Operational domain - mode, state, tasks.
Navigation domain - localization, path, obstacles.
perception: Option<PerceptionDomain>Perception domain - sensors, detections.
safety: Option<SafetyDomain>Safety domain - e-stop, zones, violations.
actuators: Option<ActuatorsDomain>Actuators domain - motors, joints, grippers.
communication: Option<CommunicationDomain>Communication domain - network, fleet comms.
compute: Option<ComputeDomain>Compute domain - CPU, memory, processes.
ai: Option<AiDomain>AI domain - models, decisions, anomalies.
maintenance: Option<MaintenanceDomain>Maintenance domain - component health, diagnostics.
context: Option<ContextDomain>Context domain - time, facility, weather context.
payload: Option<PayloadDomain>Payload domain - carried items, compartments.
manipulation: Option<ManipulationDomain>Manipulation domain - arms, grippers, workspace.
hri: Option<HriDomain>HRI domain - human interaction, social navigation.
coordination: Option<CoordinationDomain>Coordination domain - fleet coordination, formations.
simulation: Option<SimulationDomain>Simulation domain - simulator info, scenarios.
thermal: Option<ThermalDomain>Thermal domain - temperatures, cooling.
audio: Option<AudioDomain>Audio domain - microphones, speakers, sounds.
environment_interaction: Option<EnvironmentInteractionDomain>Environment interaction domain - doors, elevators.
compliance: Option<ComplianceDomain>Compliance domain - certifications, safety standards.
provenance: Option<Provenance>Provenance information for data integrity.
extensions: Option<Value>Extension point for custom data.
Implementations§
Source§impl UdmEvent
impl UdmEvent
Sourcepub fn new(source_type: SourceType) -> Self
pub fn new(source_type: SourceType) -> Self
Create a new UDM event with required fields.
Automatically generates a UUIDv7 event ID and sets the captured_at timestamp.
Sourcepub fn with_event_type(self, event_type: EventType) -> Self
pub fn with_event_type(self, event_type: EventType) -> Self
Set the event type.
Sourcepub fn with_identity(self, identity: IdentityDomain) -> Self
pub fn with_identity(self, identity: IdentityDomain) -> Self
Set the identity domain.
Sourcepub fn with_location(self, location: LocationDomain) -> Self
pub fn with_location(self, location: LocationDomain) -> Self
Set the location domain.
Sourcepub fn with_motion(self, motion: MotionDomain) -> Self
pub fn with_motion(self, motion: MotionDomain) -> Self
Set the motion domain.
Sourcepub fn with_power(self, power: PowerDomain) -> Self
pub fn with_power(self, power: PowerDomain) -> Self
Set the power domain.
Sourcepub fn with_operational(self, operational: OperationalDomain) -> Self
pub fn with_operational(self, operational: OperationalDomain) -> Self
Set the operational domain.
Set the navigation domain.
Sourcepub fn with_perception(self, perception: PerceptionDomain) -> Self
pub fn with_perception(self, perception: PerceptionDomain) -> Self
Set the perception domain.
Sourcepub fn with_safety(self, safety: SafetyDomain) -> Self
pub fn with_safety(self, safety: SafetyDomain) -> Self
Set the safety domain.
Sourcepub fn with_actuators(self, actuators: ActuatorsDomain) -> Self
pub fn with_actuators(self, actuators: ActuatorsDomain) -> Self
Set the actuators domain.
Sourcepub fn with_communication(self, communication: CommunicationDomain) -> Self
pub fn with_communication(self, communication: CommunicationDomain) -> Self
Set the communication domain.
Sourcepub fn with_compute(self, compute: ComputeDomain) -> Self
pub fn with_compute(self, compute: ComputeDomain) -> Self
Set the compute domain.
Sourcepub fn with_maintenance(self, maintenance: MaintenanceDomain) -> Self
pub fn with_maintenance(self, maintenance: MaintenanceDomain) -> Self
Set the maintenance domain.
Sourcepub fn with_context(self, context: ContextDomain) -> Self
pub fn with_context(self, context: ContextDomain) -> Self
Set the context domain.
Sourcepub fn with_payload(self, payload: PayloadDomain) -> Self
pub fn with_payload(self, payload: PayloadDomain) -> Self
Set the payload domain.
Sourcepub fn with_manipulation(self, manipulation: ManipulationDomain) -> Self
pub fn with_manipulation(self, manipulation: ManipulationDomain) -> Self
Set the manipulation domain.
Sourcepub fn with_coordination(self, coordination: CoordinationDomain) -> Self
pub fn with_coordination(self, coordination: CoordinationDomain) -> Self
Set the coordination domain.
Sourcepub fn with_simulation(self, simulation: SimulationDomain) -> Self
pub fn with_simulation(self, simulation: SimulationDomain) -> Self
Set the simulation domain.
Sourcepub fn with_thermal(self, thermal: ThermalDomain) -> Self
pub fn with_thermal(self, thermal: ThermalDomain) -> Self
Set the thermal domain.
Sourcepub fn with_audio(self, audio: AudioDomain) -> Self
pub fn with_audio(self, audio: AudioDomain) -> Self
Set the audio domain.
Sourcepub fn with_environment_interaction(
self,
environment_interaction: EnvironmentInteractionDomain,
) -> Self
pub fn with_environment_interaction( self, environment_interaction: EnvironmentInteractionDomain, ) -> Self
Set the environment interaction domain.
Sourcepub fn with_compliance(self, compliance: ComplianceDomain) -> Self
pub fn with_compliance(self, compliance: ComplianceDomain) -> Self
Set the compliance domain.
Sourcepub fn with_extensions(self, extensions: Value) -> Self
pub fn with_extensions(self, extensions: Value) -> Self
Set custom extensions.
Sourcepub fn inject_license_metadata(&mut self, metadata: &LicenseMetadata)
pub fn inject_license_metadata(&mut self, metadata: &LicenseMetadata)
Inject license metadata into the event’s extensions.
This is called automatically by the agent before sending events.
Sourcepub fn with_provenance(self, provenance: Provenance) -> Self
pub fn with_provenance(self, provenance: Provenance) -> Self
Set provenance information.
Sourcepub fn has_domain_data(&self) -> bool
pub fn has_domain_data(&self) -> bool
Check if the event has any domain data.
Sourcepub fn estimated_size(&self) -> usize
pub fn estimated_size(&self) -> usize
Get estimated size in bytes (serialized JSON).
Sourcepub fn to_json_pretty(&self) -> Result<String, Error>
pub fn to_json_pretty(&self) -> Result<String, Error>
Serialize to pretty JSON string.