ConfigurationOption

Struct ConfigurationOption 

Source
pub struct ConfigurationOption;
Expand description

Configuration Option - DNS-SD style TXT record format (no_std compatible).

Provides zero-copy parsing and serialization of configuration options following the DNS-SD TXT record format used in SOME/IP-SD.

Wire format:

[len1][string1][len2][string2]...[0x00]

Each string can be:

  • Boolean flag: “enabled”
  • Key with empty value: “name=”
  • Key with value: “version=1.0”

Implementations§

Source§

impl ConfigurationOption

Source

pub fn parse<'a>(data: &'a [u8]) -> ConfigEntryIter<'a>

Parse configuration entries from wire format (zero-copy iterator).

§Parameters
  • data - Wire format buffer: [len][string][len][string]...[0x00]
§Returns

An iterator over Result<ConfigEntry, ConfigError>

§Example
use someip_sd_wire::config::ConfigurationOption;
 
let data = b"\x07enabled\x0cversion=1.0a\x00";
let mut count = 0;
for result in ConfigurationOption::parse(data) {
    let entry = result.unwrap();
    count += 1;
    if count == 1 {
        assert_eq!(entry.key(), "enabled");
        assert!(entry.is_flag());
    }
}
assert_eq!(count, 2);
Source

pub fn serialize<'a, I>( entries: I, buf: &mut [u8], ) -> Result<usize, ConfigError>
where I: IntoIterator<Item = ConfigEntry<'a>>,

Serialize configuration entries to wire format.

§Parameters
  • entries - Iterator over ConfigEntry items to serialize
  • buf - Output buffer for wire format data
§Returns
  • Ok(usize) - Number of bytes written (including terminator)
  • Err(ConfigError) - If buffer is too small or entry exceeds 255 bytes
§Example
use someip_sd_wire::config::{ConfigEntry, ConfigurationOption};
 
let mut buf = [0u8; 64];
let entries = [
    ConfigEntry::flag("enabled").unwrap(),
    ConfigEntry::with_value("version", "1.0").unwrap(),
];
let size = ConfigurationOption::serialize(entries, &mut buf).unwrap();
assert!(size > 0);
assert_eq!(buf[size - 1], 0); // Ends with null terminator
Source

pub fn wire_size<'a, I>(entries: I) -> usize
where I: IntoIterator<Item = ConfigEntry<'a>>,

Calculate total wire format size for entries

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