Skip to main content

TxtRecord

Struct TxtRecord 

Source
pub struct TxtRecord { /* private fields */ }
Available on crate feature alloc only.
Expand description

A DNS-SD TXT record: ordered keys, each with a value or none.

Keys compare case-insensitively and are unique: the first occurrence of a key wins (RFC 6763 section 6.4). Values are bytes.

Implementations§

Source§

impl TxtRecord

Source

pub fn new() -> Self

An empty record.

Source

pub fn from_strings<I, S>(strings: I) -> Self
where I: IntoIterator<Item = S>, S: AsRef<[u8]>,

Decode the strings of a received record. Each splits at its first =; one without = is a key with no value, and one with an empty key is skipped. Keys are decoded as UTF-8 with replacement and lowercased (ebus.py:136-153); a later duplicate of a key is dropped.

Source

pub fn insert_raw(&mut self, key: String, value: Option<Vec<u8>>) -> bool

Add key with value unless the record already holds the key; returns whether it was added.

Source

pub fn insert(&mut self, key: &str, value: &str) -> bool

Add key=value unless the record already holds the key; returns whether it was added.

Source

pub fn contains_key(&self, key: &str) -> bool

True when the record holds key.

Source

pub fn get(&self, key: &str) -> Option<Cow<'_, str>>

The value of key as text, decoded as UTF-8 with replacement; "" for a key with no value; None when the key is absent.

Source

pub fn get_raw(&self, key: &str) -> Option<Option<&[u8]>>

The raw value of key: Some(None) for a key with no value.

Source

pub fn iter(&self) -> impl Iterator<Item = (&str, Option<&[u8]>)> + '_

The entries in order.

Source

pub fn len(&self) -> usize

The number of keys.

Source

pub fn is_empty(&self) -> bool

True when the record holds no key.

Source

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

The record’s strings, key=value or key, in order.

Source

pub fn wire_size(&self) -> usize

Bytes the record occupies on the wire: a length byte per string.

Trait Implementations§

Source§

impl Clone for TxtRecord

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TxtRecord

Source§

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

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

impl Default for TxtRecord

Source§

fn default() -> Self

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

impl Eq for TxtRecord

Source§

impl Hash for TxtRecord

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for TxtRecord

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for TxtRecord

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, 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.