domain::rdata::rfc1035

Struct TxtBuilder

source
pub struct TxtBuilder<Builder> { /* private fields */ }
Expand description

Iteratively build TXT record data.

This type allows building TXT record data by starting with empty data and appending either complete character strings or slices of data.

Implementations§

source§

impl<Builder: OctetsBuilder + EmptyBuilder> TxtBuilder<Builder>

source

pub fn new() -> Self

Creates a new, empty TXT builder.

source§

impl TxtBuilder<BytesMut>

source

pub fn new_bytes() -> Self

Creates a new, empty TXT builder using BytesMut.

source§

impl<Builder: OctetsBuilder + AsRef<[u8]> + AsMut<[u8]>> TxtBuilder<Builder>

source

pub fn append_slice(&mut self, slice: &[u8]) -> Result<(), TxtAppendError>

Appends a slice to the builder.

The method breaks up the slice into individual octets strings if necessary. If a previous call has started a new octets string, it fills this one up first before creating a new one. Thus, by using this method only, the resulting TXT record data will consist of character strings where all but the last one are 255 octets long.

You can force a character string break by calling close_charstr.

The method will return an error if appending the slice would result in exceeding the record data length limit or the underlying builder runs out of space. In this case, the method may have appended some data already. I.e., you should consider the builder corrupt if the method returns an error.

source

pub fn append_u8(&mut self, ch: u8) -> Result<(), TxtAppendError>

Appends a single octet.

This method calls append_slice, so all the caveats described there apply.

source

pub fn append_charstr<Octs: AsRef<[u8]> + ?Sized>( &mut self, s: &CharStr<Octs>, ) -> Result<(), TxtAppendError>

Appends a complete character string.

If a character string had previously been started by a call to append_slice, this string is closed before appending the provided character string.

The method will return an error if appending the slice would result in exceeding the record data length limit or the underlying builder runs out of space. In this case, the method may have appended some data already. I.e., you should consider the builder corrupt if the method returns an error.

source

pub fn close_charstr(&mut self)

Ends a character string.

If a previous call to append_slice started a new character string, a call to this method will close it.

source

pub fn finish(self) -> Result<Txt<Builder::Octets>, TxtAppendError>
where Builder: FreezeBuilder,

Finishes the builder and returns TXT record data.

If the builder is empty, appends an empty character string before returning. If that fails because the builder does not have enough space, returns an error.

Trait Implementations§

source§

impl<Builder: Clone> Clone for TxtBuilder<Builder>

source§

fn clone(&self) -> TxtBuilder<Builder>

Returns a copy 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<Builder: Debug> Debug for TxtBuilder<Builder>

source§

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

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

impl<Builder: OctetsBuilder + EmptyBuilder> Default for TxtBuilder<Builder>

source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<Builder> Freeze for TxtBuilder<Builder>
where Builder: Freeze,

§

impl<Builder> RefUnwindSafe for TxtBuilder<Builder>
where Builder: RefUnwindSafe,

§

impl<Builder> Send for TxtBuilder<Builder>
where Builder: Send,

§

impl<Builder> Sync for TxtBuilder<Builder>
where Builder: Sync,

§

impl<Builder> Unpin for TxtBuilder<Builder>
where Builder: Unpin,

§

impl<Builder> UnwindSafe for TxtBuilder<Builder>
where Builder: UnwindSafe,

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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<Source, Target> OctetsInto<Target> for Source
where Target: OctetsFrom<Source>,

source§

type Error = <Target as OctetsFrom<Source>>::Error

source§

fn try_octets_into( self, ) -> Result<Target, <Source as OctetsInto<Target>>::Error>

Performs the conversion.
source§

fn octets_into(self) -> Target
where Self::Error: Into<Infallible>,

Performs an infallible conversion.
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
source§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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 = 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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more