ExtendedHeader

Struct ExtendedHeader 

Source
pub struct ExtendedHeader {
    pub extended_header_size: u16,
    pub metadata_header_size: u16,
    pub metadata_size: u32,
    pub message_id: u32,
    pub additional_fields: Vec<u8>,
}
Expand description

OpenIGTLink Version 3 Extended Header structure

The Extended Header is a fixed 12-byte structure (minimum) that appears immediately after the standard 58-byte header when version >= 3.

§Structure (12 bytes minimum)

  • extended_header_size (2 bytes) - Total size including this field and any additional fields
  • metadata_header_size (2 bytes) - Number of metadata key-value pairs
  • metadata_size (4 bytes) - Total metadata size in bytes
  • message_id (4 bytes) - Unique message identifier
  • additional_fields (variable) - Optional implementation-specific data

§C++ Compatibility

This structure matches the igtlMessageHeader.h ExtendedHeader format from the OpenIGTLink C++ reference implementation.

Fields§

§extended_header_size: u16

Total size of extended header in bytes (including this field) Minimum value: 12 (for standard Extended Header) Larger values indicate additional implementation-specific fields

§metadata_header_size: u16

Number of metadata key-value pairs that follow the message content This is a count, not a size in bytes

§metadata_size: u32

Total size of metadata section in bytes (not including this Extended Header) The metadata section appears at the end of the message body

§message_id: u32

Unique message identifier for this message Can be used for:

  • Request/response correlation
  • Message tracking and debugging
  • Transfer checkpointing and resumption
§additional_fields: Vec<u8>

Additional implementation-specific fields (if extended_header_size > 12) These are optional and can contain custom protocol extensions

Implementations§

Source§

impl ExtendedHeader

Source

pub const MIN_SIZE: usize = 12usize

Minimum Extended Header size (standard fields only)

Source

pub fn new() -> Self

Create a new Extended Header with default values

§Returns

Extended Header with:

  • extended_header_size = 12 (minimum)
  • metadata_header_size = 0
  • metadata_size = 0
  • message_id = 0
  • no additional fields
Source

pub fn with_metadata(metadata_count: u16, metadata_size: u32) -> Self

Create an Extended Header with metadata information

§Arguments
  • metadata_count - Number of metadata key-value pairs
  • metadata_size - Total metadata size in bytes
§Returns

Extended Header configured for metadata

Source

pub fn with_message_id(message_id: u32) -> Self

Create an Extended Header with a message ID

§Arguments
  • message_id - Unique message identifier
§Returns

Extended Header with the specified message ID

Source

pub fn set_additional_fields(&mut self, data: Vec<u8>)

Add additional implementation-specific fields

§Arguments
  • data - Additional field data
§Notes

This automatically updates extended_header_size to include the additional data

Source

pub fn encode(&self) -> Vec<u8>

Encode the Extended Header to bytes

§Returns

Byte vector containing the encoded Extended Header

Source

pub fn decode(data: &[u8]) -> Result<Self>

Decode an Extended Header from bytes

§Arguments
  • data - Byte slice containing at least 12 bytes
§Returns

Decoded Extended Header or error

§Errors

Returns error if data is less than 12 bytes or if extended_header_size is less than 12 or larger than available data

Source

pub fn size(&self) -> usize

Get the total size of this Extended Header

Source

pub fn has_metadata(&self) -> bool

Check if this Extended Header indicates metadata is present

Source

pub fn get_metadata_size(&self) -> usize

Get the metadata size in bytes (size of metadata data)

Source

pub fn get_metadata_header_size(&self) -> usize

Get the metadata header size in bytes (size of metadata structure definitions)

Source

pub fn get_metadata_count(&self) -> usize

👎Deprecated: Use get_metadata_header_size() instead - metadata_header_size is size in bytes, not count

Get the number of metadata entries (deprecated - metadata_header_size is not entry count)

Source

pub fn get_message_id(&self) -> u32

Get the message ID

Trait Implementations§

Source§

impl Clone for ExtendedHeader

Source§

fn clone(&self) -> ExtendedHeader

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

impl Debug for ExtendedHeader

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for ExtendedHeader

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for ExtendedHeader

Source§

fn eq(&self, other: &ExtendedHeader) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for ExtendedHeader

Source§

impl StructuralPartialEq for ExtendedHeader

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.

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