Struct dns_parser::Builder [−][src]
Allows to build a DNS packet
Both query and answer packets may be built with this interface, although, much of functionality is not implemented yet.
Implementations
impl Builder
[src]
pub fn new_query(id: u16, recursion: bool) -> Builder
[src]
Creates a new query
Initially all sections are empty. You’re expected to fill
the questions section with add_question
pub fn add_question(
&mut self,
qname: &str,
prefer_unicast: bool,
qtype: QueryType,
qclass: QueryClass
) -> &mut Builder
[src]
&mut self,
qname: &str,
prefer_unicast: bool,
qtype: QueryType,
qclass: QueryClass
) -> &mut Builder
Adds a question to the packet
Panics
- Answers, nameservers or additional section has already been written
- There are already 65535 questions in the buffer.
- When name is invalid
pub fn build(self) -> Result<Vec<u8>, Vec<u8>>
[src]
Returns the final packet
When packet is not truncated method returns Ok(packet)
. If
packet is truncated the method returns Err(packet)
. In both
cases the packet is fully valid.
In the server implementation you may use
x.build().unwrap_or_else(|x| x)
.
In the client implementation it’s probably unwise to send truncated packet, as it doesn’t make sense. Even panicking may be more appropriate.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Builder
impl Send for Builder
impl Sync for Builder
impl Unpin for Builder
impl UnwindSafe for Builder
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,