EventBuilder

Struct EventBuilder 

Source
pub struct EventBuilder { /* private fields */ }
Expand description

Fluent builder for UDM events.

§Example

use phytrace_sdk::core::{EventBuilder, PhyTraceConfig};
use phytrace_sdk::{EventType, SourceType};

let config = PhyTraceConfig::new("robot-001")
    .with_source_type(SourceType::Amr);

let event = EventBuilder::new(&config)
    .event_type(EventType::TelemetryPeriodic)
    .position_local(10.0, 20.0, 0.0)
    .heading_deg(90.0)
    .battery_soc(85.0)
    .build()
    .unwrap();

Implementations§

Source§

impl EventBuilder

Source

pub fn new(config: &PhyTraceConfig) -> Self

Create a new event builder with configuration.

Source

pub fn event_type(self, event_type: EventType) -> Self

Set the event type.

Source

pub fn source_type(self, source_type: SourceType) -> Self

Override the source type.

Source

pub fn source_id(self, source_id: impl Into<String>) -> Self

Set the source ID (robot/system identifier). This sets both the top-level source_id (for PhyCloud) and the identity domain.

Source

pub fn model_info( self, _manufacturer: impl Into<String>, model: impl Into<String>, firmware: impl Into<String>, ) -> Self

Set model/firmware information.

Source

pub fn tag(self, tag: impl Into<String>) -> Self

Add a tag.

Source

pub fn position_local(self, x: f64, y: f64, z: f64) -> Self

Set local position (x, y, z in meters).

Source

pub fn position_2d(self, x: f64, y: f64) -> Self

Set 2D position (convenience for x, y only).

Source

pub fn position_3d(self, x: f64, y: f64, z: f64) -> Self

Set 3D position (convenience alias).

Source

pub fn heading_deg(self, heading: f64) -> Self

Set heading in degrees (0-360).

Source

pub fn heading(self, heading_rad: f64) -> Self

Set heading in radians (converted to degrees).

Source

pub fn gps(self, latitude: f64, longitude: f64) -> Self

Set GPS coordinates.

Source

pub fn floor(self, floor: i32) -> Self

Set floor number.

Source

pub fn map(self, map_id: impl Into<String>, frame_id: impl Into<String>) -> Self

Set map ID and frame.

Source

pub fn linear_velocity(self, vx: f64, vy: f64, vz: f64) -> Self

Set linear velocity (m/s).

Source

pub fn angular_velocity( self, roll_rps: f64, pitch_rps: f64, yaw_rps: f64, ) -> Self

Set angular velocity (rad/s) - converts to degrees/s internally.

Source

pub fn speed(self, speed_mps: f64) -> Self

Set speed (m/s) - for 2D motion.

Source

pub fn battery_soc(self, soc_percent: f64) -> Self

Set battery state of charge (0-100%).

Source

pub fn battery_voltage(self, voltage_v: f64) -> Self

Set battery voltage.

Source

pub fn battery_health(self, health_percent: f64) -> Self

Set battery health (0-100%).

Source

pub fn charging(self, is_charging: bool) -> Self

Set charging status.

Source

pub fn operational_mode(self, mode: OperationalMode) -> Self

Set operational mode.

Source

pub fn operational_state(self, state: OperationalState) -> Self

Set operational state.

Source

pub fn task( self, task_id: impl Into<String>, task_type: impl Into<String>, ) -> Self

Set current task.

Source

pub fn safety_state(self, state: SafetyState) -> Self

Set safety state.

Source

pub fn estop_active(self, active: bool) -> Self

Set e-stop status.

Source

pub fn localization_quality(self, quality: LocalizationQuality) -> Self

Set localization quality.

Source

pub fn path_state(self, state: PathState) -> Self

Set path state.

Source

pub fn identity(self, identity: IdentityDomain) -> Self

Set the full identity domain.

Source

pub fn location(self, location: LocationDomain) -> Self

Set the full location domain.

Source

pub fn motion(self, motion: MotionDomain) -> Self

Set the full motion domain.

Source

pub fn power(self, power: PowerDomain) -> Self

Set the full power domain.

Source

pub fn operational(self, operational: OperationalDomain) -> Self

Set the full operational domain.

Source

pub fn navigation(self, navigation: NavigationDomain) -> Self

Set the full navigation domain.

Source

pub fn perception(self, perception: PerceptionDomain) -> Self

Set the full perception domain.

Source

pub fn safety(self, safety: SafetyDomain) -> Self

Set the full safety domain.

Source

pub fn actuators(self, actuators: ActuatorsDomain) -> Self

Set the full actuators domain.

Source

pub fn communication(self, communication: CommunicationDomain) -> Self

Set the full communication domain.

Source

pub fn compute(self, compute: ComputeDomain) -> Self

Set the full compute domain.

Source

pub fn ai(self, ai: AiDomain) -> Self

Set the full AI domain.

Source

pub fn maintenance(self, maintenance: MaintenanceDomain) -> Self

Set the full maintenance domain.

Source

pub fn context(self, context: ContextDomain) -> Self

Set the full context domain.

Source

pub fn payload(self, payload: PayloadDomain) -> Self

Set the full payload domain.

Source

pub fn manipulation(self, manipulation: ManipulationDomain) -> Self

Set the full manipulation domain.

Source

pub fn hri(self, hri: HriDomain) -> Self

Set the full HRI domain.

Source

pub fn coordination(self, coordination: CoordinationDomain) -> Self

Set the full coordination domain.

Source

pub fn simulation(self, simulation: SimulationDomain) -> Self

Set the full simulation domain.

Source

pub fn thermal(self, thermal: ThermalDomain) -> Self

Set the full thermal domain.

Source

pub fn audio(self, audio: AudioDomain) -> Self

Set the full audio domain.

Source

pub fn environment_interaction( self, environment_interaction: EnvironmentInteractionDomain, ) -> Self

Set the full environment interaction domain.

Source

pub fn compliance(self, compliance: ComplianceDomain) -> Self

Set the full compliance domain.

Source

pub fn extensions(self, extensions: Value) -> Self

Set custom extensions.

Source

pub fn build(self) -> PhyTraceResult<UdmEvent>

Build the event, validating and optionally signing.

Source

pub fn build_unchecked(self) -> UdmEvent

Build without validation.

Source

pub fn peek(&self) -> &UdmEvent

Get a reference to the event being built.

Trait Implementations§

Source§

impl Clone for EventBuilder

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more