ConfigEntry

Struct ConfigEntry 

Source
pub struct ConfigEntry<'a> { /* private fields */ }
Expand description

A single configuration entry reference (zero-copy, no_std compatible).

Configuration entries follow DNS-SD TXT record format:

  • Key-only (boolean flag): "enabled"
  • Key with empty value: "name="
  • Key with value: "version=1.0"

Keys must be printable US-ASCII (0x20-0x7E) excluding ‘=’.

Implementations§

Source§

impl<'a> ConfigEntry<'a>

Source

pub fn new(key: &'a str, value: Option<&'a str>) -> Result<Self, ConfigError>

Create a new entry with a key and optional value.

§Parameters
  • key - The entry key (printable ASCII, no ‘=’)
  • value - None for boolean flag, Some(str) for key=value
§Returns
  • Ok(ConfigEntry) if key is valid
  • Err(ConfigError::InvalidKey) if key is malformed
Source

pub fn flag(key: &'a str) -> Result<Self, ConfigError>

Create a boolean flag entry (key only, no value).

§Parameters
  • key - The flag name
§Returns
  • Ok(ConfigEntry) if key is valid
  • Err(ConfigError::InvalidKey) if key is malformed
Source

pub fn with_value(key: &'a str, value: &'a str) -> Result<Self, ConfigError>

Create an entry with a value.

§Parameters
  • key - The entry key
  • value - The entry value
§Returns
  • Ok(ConfigEntry) if key is valid
  • Err(ConfigError::InvalidKey) if key is malformed
Source

pub fn key(&self) -> &'a str

Get the entry key.

§Returns

The key string slice

Source

pub fn value(&self) -> Option<&'a str>

Get the entry value if present.

§Returns
  • None if this is a boolean flag
  • Some("") if key ends with ‘=’
  • Some(value) if key=value
Source

pub fn is_flag(&self) -> bool

Check if this is a boolean flag (no value).

§Returns

True if entry is key-only, false if key=value

Source

pub fn from_str(s: &'a str) -> Result<Self, ConfigError>

Parse a configuration entry from a string (without length byte).

§Parameters
  • s - The string to parse (e.g., “key=value” or “flag”)
§Returns
  • Ok(ConfigEntry) if parse succeeds
  • Err(ConfigError) if format is invalid
Source

pub fn write_to(&self, buf: &mut [u8]) -> Result<usize, ConfigError>

Write entry to buffer (without length prefix).

§Parameters
  • buf - The buffer to write into
§Returns
  • Ok(usize) - Number of bytes written
  • Err(ConfigError::BufferTooSmall) if buffer is insufficient
Source

pub fn wire_size(&self) -> usize

Calculate wire format size (without length prefix).

§Returns

Number of bytes needed for the entry data (excluding length byte)

Trait Implementations§

Source§

impl<'a> Clone for ConfigEntry<'a>

Source§

fn clone(&self) -> ConfigEntry<'a>

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<'a> Debug for ConfigEntry<'a>

Source§

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

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

impl<'a> PartialEq for ConfigEntry<'a>

Source§

fn eq(&self, other: &ConfigEntry<'a>) -> 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<'a> Copy for ConfigEntry<'a>

Source§

impl<'a> Eq for ConfigEntry<'a>

Source§

impl<'a> StructuralPartialEq for ConfigEntry<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for ConfigEntry<'a>

§

impl<'a> RefUnwindSafe for ConfigEntry<'a>

§

impl<'a> Send for ConfigEntry<'a>

§

impl<'a> Sync for ConfigEntry<'a>

§

impl<'a> Unpin for ConfigEntry<'a>

§

impl<'a> UnwindSafe for ConfigEntry<'a>

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.