Struct domain::rdata::rfc1035::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>
impl<Builder: OctetsBuilder + EmptyBuilder> TxtBuilder<Builder>
source§impl TxtBuilder<BytesMut>
impl TxtBuilder<BytesMut>
source§impl<Builder: OctetsBuilder + AsRef<[u8]> + AsMut<[u8]>> TxtBuilder<Builder>
impl<Builder: OctetsBuilder + AsRef<[u8]> + AsMut<[u8]>> TxtBuilder<Builder>
sourcepub fn append_slice(&mut self, slice: &[u8]) -> Result<(), TxtAppendError>
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.
sourcepub fn append_u8(&mut self, ch: u8) -> Result<(), TxtAppendError>
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.
sourcepub fn append_charstr<Octs: AsRef<[u8]> + ?Sized>(
&mut self,
s: &CharStr<Octs>,
) -> Result<(), TxtAppendError>
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.
sourcepub fn close_charstr(&mut self)
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.
sourcepub fn finish(self) -> Result<Txt<Builder::Octets>, TxtAppendError>where
Builder: FreezeBuilder,
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>
impl<Builder: Clone> Clone for TxtBuilder<Builder>
source§fn clone(&self) -> TxtBuilder<Builder>
fn clone(&self) -> TxtBuilder<Builder>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<Builder: Debug> Debug for TxtBuilder<Builder>
impl<Builder: Debug> Debug for TxtBuilder<Builder>
source§impl<Builder: OctetsBuilder + EmptyBuilder> Default for TxtBuilder<Builder>
impl<Builder: OctetsBuilder + EmptyBuilder> Default for TxtBuilder<Builder>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)