ServiceEntry

Struct ServiceEntry 

Source
pub struct ServiceEntry<T: AsRef<[u8]>> { /* private fields */ }
Expand description

Zero-copy wrapper around a Service Entry (16 bytes).

Service entries are used for FindService and OfferService messages in SOME/IP-SD. They contain information about service availability and discovery.

§Wire Format

Byte 0:    Type (0x00=FindService, 0x01=OfferService)
Byte 1:    Index1stOptions (4-bit) | Index2ndOptions (4-bit)
Byte 2:    # of opt 1 (4-bit) | # of opt 2 (4-bit)
Byte 3:    Service ID (high byte)
Byte 4:    Service ID (low byte)
Byte 5:    Instance ID (high byte)
Byte 6:    Instance ID (low byte)
Byte 7:    Major Version
Byte 8-10: TTL (24-bit, 0xFFFFFF=infinite, 0x000000=stop)
Byte 11-14: Minor Version (32-bit)

Implementations§

Source§

impl<T: AsRef<[u8]>> ServiceEntry<T>

Source

pub const LENGTH: usize = 16usize

Size of a service entry in bytes.

Source

pub fn new_unchecked(buffer: T) -> Self

Creates a new unchecked ServiceEntry from a buffer.

§Parameters
  • buffer - Buffer containing service entry data
§Safety

This does not validate buffer length. Use new_checked for validation.

Source

pub fn new_checked(buffer: T) -> Result<Self>

Create a ServiceEntry from a buffer with length validation.

§Parameters
  • buffer - The buffer containing the 16-byte service entry
§Returns
  • Ok(ServiceEntry) if buffer is at least 16 bytes
  • Err(Error) if buffer is too short
Source

pub fn check_len(&self) -> Result<()>

Validate that the buffer is at least 16 bytes long.

§Returns
  • Ok(()) if buffer meets minimum length requirement
  • Err(Error) if buffer is too short
Source

pub fn check_entry_type(&self) -> Result<()>

Validate the entry has a valid service entry type.

§Returns
  • Ok(()) if entry type is FindService (0x00) or OfferService (0x01)
  • Err(Error::InvalidEntryType) if entry type is invalid for service entries
Source

pub fn entry_type(&self) -> u8

Get the entry type field (1 byte at offset 0).

§Returns

Entry type value (0x00=FindService, 0x01=OfferService)

Source

pub fn index_first_option_run(&self) -> u8

Get the index of the first option run (1 byte at offset 1).

§Returns

Index into the options array for the first run, or 0 if no options

Source

pub fn index_second_option_run(&self) -> u8

Get the index of the second option run (1 byte at offset 2).

§Returns

Index into the options array for the second run, or 0 if no second run

Source

pub fn number_of_options(&self) -> NumberOfOptions

Get the packed number of options (1 byte at offset 3).

§Returns

NumberOfOptions containing 4-bit counts for two option runs

Source

pub fn service_id(&self) -> u16

Get the Service ID (2 bytes at offset 4-5, network byte order).

§Returns

16-bit Service ID identifying the service

Source

pub fn instance_id(&self) -> u16

Get the Instance ID (2 bytes at offset 6-7, network byte order).

§Returns

16-bit Instance ID identifying the service instance

Source

pub fn major_version(&self) -> u8

Get the Major Version (1 byte at offset 8).

§Returns

8-bit major version of the service interface

Source

pub fn ttl(&self) -> u32

Get the TTL (Time To Live) field (3 bytes at offset 9-11).

§Returns

24-bit TTL in seconds, or 0xFFFFFF for infinite lifetime

Source

pub fn minor_version(&self) -> u32

Get the Minor Version (4 bytes at offset 12-15, network byte order).

§Returns

32-bit minor version of the service interface

Source§

impl<T: AsRef<[u8]> + AsMut<[u8]>> ServiceEntry<T>

Source

pub fn set_entry_type(&mut self, value: u8)

Set the entry type field (1 byte at offset 0).

§Parameters
  • value - Entry type value (0x00=FindService, 0x01=OfferService)
Source

pub fn set_index_first_option_run(&mut self, value: u8)

Set the index of the first option run (1 byte at offset 1).

§Parameters
  • value - Index into the options array for the first run
Source

pub fn set_index_second_option_run(&mut self, value: u8)

Set the index of the second option run (1 byte at offset 2).

§Parameters
  • value - Index into the options array for the second run
Source

pub fn set_number_of_options(&mut self, value: NumberOfOptions)

Set the packed number of options (1 byte at offset 3).

§Parameters
  • value - NumberOfOptions containing 4-bit counts for two option runs
Source

pub fn set_service_id(&mut self, value: u16)

Set the Service ID (2 bytes at offset 4-5, network byte order).

§Parameters
  • value - 16-bit Service ID identifying the service
Source

pub fn set_instance_id(&mut self, value: u16)

Set the Instance ID (2 bytes at offset 6-7, network byte order).

§Parameters
  • value - 16-bit Instance ID identifying the service instance
Source

pub fn set_major_version(&mut self, value: u8)

Set the Major Version (1 byte at offset 8).

§Parameters
  • value - 8-bit major version of the service interface
Source

pub fn set_ttl(&mut self, value: u32)

Set the TTL (Time To Live) field (3 bytes at offset 9-11).

§Parameters
  • value - 24-bit TTL in seconds (lower 24 bits used), or 0xFFFFFF for infinite
Source

pub fn set_minor_version(&mut self, value: u32)

Set the Minor Version (4 bytes at offset 12-15, network byte order).

§Parameters
  • value - 32-bit minor version of the service interface

Trait Implementations§

Source§

impl<T: Clone + AsRef<[u8]>> Clone for ServiceEntry<T>

Source§

fn clone(&self) -> ServiceEntry<T>

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<T: Debug + AsRef<[u8]>> Debug for ServiceEntry<T>

Source§

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

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

impl<T: Copy + AsRef<[u8]>> Copy for ServiceEntry<T>

Auto Trait Implementations§

§

impl<T> Freeze for ServiceEntry<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for ServiceEntry<T>
where T: RefUnwindSafe,

§

impl<T> Send for ServiceEntry<T>
where T: Send,

§

impl<T> Sync for ServiceEntry<T>
where T: Sync,

§

impl<T> Unpin for ServiceEntry<T>
where T: Unpin,

§

impl<T> UnwindSafe for ServiceEntry<T>
where T: UnwindSafe,

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