AnyMessage

Enum AnyMessage 

Source
pub enum AnyMessage {
Show 41 variants Transform(IgtlMessage<TransformMessage>), Status(IgtlMessage<StatusMessage>), Capability(IgtlMessage<CapabilityMessage>), Image(IgtlMessage<ImageMessage>), Position(IgtlMessage<PositionMessage>), String(IgtlMessage<StringMessage>), QtData(IgtlMessage<QtDataMessage>), TData(IgtlMessage<TDataMessage>), Sensor(IgtlMessage<SensorMessage>), Point(IgtlMessage<PointMessage>), Trajectory(IgtlMessage<TrajectoryMessage>), NdArray(IgtlMessage<NdArrayMessage>), Bind(IgtlMessage<BindMessage>), ColorTable(IgtlMessage<ColorTableMessage>), ImgMeta(IgtlMessage<ImgMetaMessage>), LbMeta(IgtlMessage<LbMetaMessage>), PolyData(IgtlMessage<PolyDataMessage>), Video(IgtlMessage<VideoMessage>), VideoMeta(IgtlMessage<VideoMetaMessage>), Command(IgtlMessage<CommandMessage>), GetTransform(IgtlMessage<GetTransformMessage>), GetStatus(IgtlMessage<GetStatusMessage>), GetCapability(IgtlMessage<GetCapabilityMessage>), GetImage(IgtlMessage<GetImageMessage>), GetImgMeta(IgtlMessage<GetImgMetaMessage>), GetLbMeta(IgtlMessage<GetLbMetaMessage>), GetPoint(IgtlMessage<GetPointMessage>), GetTData(IgtlMessage<GetTDataMessage>), RtsTransform(IgtlMessage<RtsTransformMessage>), RtsStatus(IgtlMessage<RtsStatusMessage>), RtsCapability(IgtlMessage<RtsCapabilityMessage>), RtsImage(IgtlMessage<RtsImageMessage>), RtsTData(IgtlMessage<RtsTDataMessage>), StartTData(IgtlMessage<StartTDataMessage>), StopTransform(IgtlMessage<StopTransformMessage>), StopPosition(IgtlMessage<StopPositionMessage>), StopQtData(IgtlMessage<StopQtDataMessage>), StopTData(IgtlMessage<StopTDataMessage>), StopImage(IgtlMessage<StopImageMessage>), StopNdArray(IgtlMessage<StopNdArrayMessage>), Unknown { header: Header, body: Vec<u8>, },
}
Expand description

Enum holding any OpenIGTLink message type

This allows receiving messages without knowing the type at compile time. The message type is determined at runtime from the header’s type_name field.

§Examples

let mut client = ClientBuilder::new().tcp("127.0.0.1:18944").sync().build()?;

let msg = client.receive_any()?;
match msg {
    AnyMessage::Transform(transform_msg) => {
        println!("Received transform from {}", transform_msg.header.device_name.as_str()?);
    }
    AnyMessage::Status(status_msg) => {
        println!("Status: {}", status_msg.content.status_string);
    }
    _ => println!("Other message type"),
}

Variants§

§

Transform(IgtlMessage<TransformMessage>)

TRANSFORM message

§

Status(IgtlMessage<StatusMessage>)

STATUS message

§

Capability(IgtlMessage<CapabilityMessage>)

CAPABILITY message

§

Image(IgtlMessage<ImageMessage>)

IMAGE message

§

Position(IgtlMessage<PositionMessage>)

POSITION message

§

String(IgtlMessage<StringMessage>)

STRING message

§

QtData(IgtlMessage<QtDataMessage>)

QTDATA message (quaternion tracking data)

§

TData(IgtlMessage<TDataMessage>)

TDATA message (tracking data)

§

Sensor(IgtlMessage<SensorMessage>)

SENSOR message

§

Point(IgtlMessage<PointMessage>)

POINT message

§

Trajectory(IgtlMessage<TrajectoryMessage>)

TRAJECTORY message

§

NdArray(IgtlMessage<NdArrayMessage>)

NDARRAY message (n-dimensional array)

§

Bind(IgtlMessage<BindMessage>)

BIND message

§

ColorTable(IgtlMessage<ColorTableMessage>)

COLORTABLE message

§

ImgMeta(IgtlMessage<ImgMetaMessage>)

IMGMETA message (image metadata)

§

LbMeta(IgtlMessage<LbMetaMessage>)

LBMETA message (label metadata)

§

PolyData(IgtlMessage<PolyDataMessage>)

POLYDATA message

§

Video(IgtlMessage<VideoMessage>)

VIDEO message

§

VideoMeta(IgtlMessage<VideoMetaMessage>)

VIDEOMETA message

§

Command(IgtlMessage<CommandMessage>)

COMMAND message

§

GetTransform(IgtlMessage<GetTransformMessage>)

GET_TRANSFORM query message

§

GetStatus(IgtlMessage<GetStatusMessage>)

GET_STATUS query message

§

GetCapability(IgtlMessage<GetCapabilityMessage>)

GET_CAPABILITY query message

§

GetImage(IgtlMessage<GetImageMessage>)

GET_IMAGE query message

§

GetImgMeta(IgtlMessage<GetImgMetaMessage>)

GET_IMGMETA query message

§

GetLbMeta(IgtlMessage<GetLbMetaMessage>)

GET_LBMETA query message

§

GetPoint(IgtlMessage<GetPointMessage>)

GET_POINT query message

§

GetTData(IgtlMessage<GetTDataMessage>)

GET_TDATA query message

§

RtsTransform(IgtlMessage<RtsTransformMessage>)

RTS_TRANSFORM response message

§

RtsStatus(IgtlMessage<RtsStatusMessage>)

RTS_STATUS response message

§

RtsCapability(IgtlMessage<RtsCapabilityMessage>)

RTS_CAPABILITY response message

§

RtsImage(IgtlMessage<RtsImageMessage>)

RTS_IMAGE response message

§

RtsTData(IgtlMessage<RtsTDataMessage>)

RTS_TDATA response message

§

StartTData(IgtlMessage<StartTDataMessage>)

STT_TDATA start streaming message

§

StopTransform(IgtlMessage<StopTransformMessage>)

STP_TRANSFORM stop streaming message

§

StopPosition(IgtlMessage<StopPositionMessage>)

STP_POSITION stop streaming message

§

StopQtData(IgtlMessage<StopQtDataMessage>)

STP_QTDATA stop streaming message

§

StopTData(IgtlMessage<StopTDataMessage>)

STP_TDATA stop streaming message

§

StopImage(IgtlMessage<StopImageMessage>)

STP_IMAGE stop streaming message

§

StopNdArray(IgtlMessage<StopNdArrayMessage>)

STP_NDARRAY stop streaming message

§

Unknown

Unknown message type (unrecognized or custom message)

Contains the header and raw body bytes for manual processing.

Fields

§header: Header

Message header

§body: Vec<u8>

Raw message body bytes

Implementations§

Source§

impl AnyMessage

Source

pub fn message_type(&self) -> &str

Get the message type name as a string

§Examples
assert_eq!(any_msg.message_type(), "TRANSFORM");
Source

pub fn device_name(&self) -> Result<&str>

Get the device name from the message header

§Examples
assert_eq!(any_msg.device_name()?, "MyDevice");
Source

pub fn header(&self) -> &Header

Get reference to the message header

Source

pub fn as_transform(&self) -> Option<&IgtlMessage<TransformMessage>>

Try to extract as a Transform message

Source

pub fn as_status(&self) -> Option<&IgtlMessage<StatusMessage>>

Try to extract as a Status message

Source

pub fn as_image(&self) -> Option<&IgtlMessage<ImageMessage>>

Try to extract as an Image message

Source

pub fn as_position(&self) -> Option<&IgtlMessage<PositionMessage>>

Try to extract as a Position message

Source

pub fn as_string(&self) -> Option<&IgtlMessage<StringMessage>>

Try to extract as a String message

Source

pub fn as_capability(&self) -> Option<&IgtlMessage<CapabilityMessage>>

Try to extract as a Capability message

Source

pub fn is_unknown(&self) -> bool

Check if this is an unknown message type

Source

pub fn decode_with_options(data: &[u8], verify_crc: bool) -> Result<Self>

Decode a message from raw bytes with optional CRC verification

This is a lower-level method that attempts to decode the message based on its type_name field in the header.

§Arguments
  • data - Raw message bytes (header + body)
  • verify_crc - Whether to verify CRC checksum
§Errors
§Examples
let msg = AnyMessage::decode_with_options(&data, true)?;

Trait Implementations§

Source§

impl Debug for AnyMessage

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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.

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.
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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