pub struct TxtRecord(_);
Expand description

Key-Value container that uses DNS TXT RDATA as representation

The binary representation can be used as RDATA for DNS-SD TXT Records (see RFC 6763, section 6).

Each entry results in one string in the TXT represenation; TXT RDATA contains many (but at least one) possibly empty strings, each up to 255 bytes.

Key and value are separated by the first = in an entry, and the key must consist of printable ASCII characters (0x20…0x7E) apart from =. Keys should be 9 characters or fewer.

Values can be any binary string (but the total length of an entry cannot exceed 255 bytes).

An entry also can have no value at all (which is different from having an empty value) if there is no = separator in the entry.

Implementations

Constructs a new, empty TxtRecord.

Parse binary blob as TXT RDATA

Same as parse but takes ownership of buffer.

Parse some binary blob as TXT RDATA

A single empty string (encoded as 0x00) gets decoded as “empty” TxtRecord (i.e. the reverse th rdata()); an empty slice is treated the same, although it wouldn’t be valid RDATA.

This only fails when the length of a chunk exceeds the remaining data.

Constructs a new, empty TxtRecord with the specified capacity.

The inserting operations will still reallocate if necessary.

Reserves capacity for at least additional more bytes to be used by inserting operations.

Each entry requires 1 byte for the total length, the length of the key for the key; if there is a value 1 byte for the separator = and the length of the value for the value.

Returns true if the TxtRecord contains no elements (both in bytes and key-value entries).

Clears the TxtRecord, removing all entries.

if not empty this returns valid TXT RDATA, otherwise just an empty slice.

always returns valid TXT RDATA; when the container is empty it will return a TXT record with a single empty string (i.e. &[0x00]).

Iterate over all (key, value) pairs.

Get value for entry with given key

Returns None if there is no such entry, Some(None) if the entry exists but has no value, and Some(Some(value)) if the entry exists and has a value.

Remove entry with given key (if it exists)

Insert or update the entry with key to have the given value or on value

Insert or update the entry with key to have no value

Insert or update the entry with key to have the given value

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

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

Which kind of iterator are we turning this into?

The type of the elements being iterated over.

Creates an iterator from a value. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.