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>
impl<T: AsRef<[u8]>> ServiceEntry<T>
Sourcepub fn new_unchecked(buffer: T) -> Self
pub fn new_unchecked(buffer: T) -> Self
Sourcepub fn new_checked(buffer: T) -> Result<Self>
pub fn new_checked(buffer: T) -> Result<Self>
Sourcepub fn check_len(&self) -> Result<()>
pub fn check_len(&self) -> Result<()>
Validate that the buffer is at least 16 bytes long.
§Returns
Ok(())if buffer meets minimum length requirementErr(Error)if buffer is too short
Sourcepub fn check_entry_type(&self) -> Result<()>
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
Sourcepub fn entry_type(&self) -> u8
pub fn entry_type(&self) -> u8
Get the entry type field (1 byte at offset 0).
§Returns
Entry type value (0x00=FindService, 0x01=OfferService)
Sourcepub fn index_first_option_run(&self) -> u8
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
Sourcepub fn index_second_option_run(&self) -> u8
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
Sourcepub fn number_of_options(&self) -> NumberOfOptions
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
Sourcepub fn service_id(&self) -> u16
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
Sourcepub fn instance_id(&self) -> u16
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
Sourcepub fn major_version(&self) -> u8
pub fn major_version(&self) -> u8
Sourcepub fn ttl(&self) -> u32
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
Sourcepub fn minor_version(&self) -> u32
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>
impl<T: AsRef<[u8]> + AsMut<[u8]>> ServiceEntry<T>
Sourcepub fn set_entry_type(&mut self, value: u8)
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)
Sourcepub fn set_index_first_option_run(&mut self, value: u8)
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
Sourcepub fn set_index_second_option_run(&mut self, value: u8)
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
Sourcepub fn set_number_of_options(&mut self, value: NumberOfOptions)
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
Sourcepub fn set_service_id(&mut self, value: u16)
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
Sourcepub fn set_instance_id(&mut self, value: u16)
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
Sourcepub fn set_major_version(&mut self, value: u8)
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
Sourcepub fn set_ttl(&mut self, value: u32)
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
Sourcepub fn set_minor_version(&mut self, value: u32)
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>
impl<T: Clone + AsRef<[u8]>> Clone for ServiceEntry<T>
Source§fn clone(&self) -> ServiceEntry<T>
fn clone(&self) -> ServiceEntry<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more