Struct Message
pub struct Message { /* private fields */ }dns and std only.Expand description
A parsed DNS message header, question section, and answer section.
Parsing deliberately stops after the answer section: the authority and
additional sections are never walked, so their records are not validated
and any EDNS(0) OPT record they carry is not read. Use
MessageHeader::authority_count and MessageHeader::additional_count
to see what was skipped.
The result stays close to the wire. Names keep their original case and trailing root label, records keep their declared class and TTL, and no section is capped or deduplicated. Normalisation and limits belong with the caller.
Message::parse is lenient, because a message that goes wrong halfway
is still worth what precedes it. Only a message shorter than its fixed
header fails outright; a question or answer that cannot be decoded ends
the walk and everything before it is kept. Message::is_complete and
Message::incomplete_reason report whether the walk ended early and
why. A question that fails also ends it before the answer section, whose
start is then unknown.
Message::parse_strict instead rejects such a message, and its error
still hands back that same partial result through
MessageParseError::partial.
Implementations§
§impl Message
impl Message
pub fn parse(message: &[u8]) -> Result<Message, MessageParseError>
pub fn parse(message: &[u8]) -> Result<Message, MessageParseError>
Parse one borrowed DNS message, keeping what decodes.
Only RDATA that outlives the call is copied. Use
Message::parse_bytes when the caller already owns the message as
Bytes and wants that RDATA to share its allocation.
pub fn parse_bytes(message: &Bytes) -> Result<Message, MessageParseError>
pub fn parse_bytes(message: &Bytes) -> Result<Message, MessageParseError>
Parse one owned DNS message, keeping what decodes, without copying its RDATA.
Retained RDATA keeps the whole message allocation alive, which is what
a proportionately sized datagram buffer wants. Use Message::parse
to copy out of an oversized or reused buffer.
pub fn parse_strict(message: &[u8]) -> Result<Message, MessageParseError>
pub fn parse_strict(message: &[u8]) -> Result<Message, MessageParseError>
Parse one borrowed DNS message, rejecting an incomplete result.
A question or answer that Message::parse would stop on is an error
here. The error carries everything parsed before it through
MessageParseError::partial.
pub fn parse_bytes_strict(message: &Bytes) -> Result<Message, MessageParseError>
pub fn parse_bytes_strict(message: &Bytes) -> Result<Message, MessageParseError>
Parse one owned DNS message, rejecting an incomplete result, without copying its RDATA.
This is Message::parse_strict with the sharing behaviour of
Message::parse_bytes.
pub const fn header(&self) -> &MessageHeader
pub const fn header(&self) -> &MessageHeader
Return the message’s header.
pub const fn questions(&self) -> &[Question]
pub const fn questions(&self) -> &[Question]
Return the message’s questions, in wire order.
This holds fewer entries than MessageHeader::question_count when
the walk ended early.
pub const fn answers(&self) -> &[ResourceRecord]
pub const fn answers(&self) -> &[ResourceRecord]
Return the message’s answer records, in wire order.
This holds fewer entries than MessageHeader::answer_count when the
walk ended early.
pub const fn is_complete(&self) -> bool
pub const fn is_complete(&self) -> bool
Return whether every question and answer the header declared was parsed.
pub fn incomplete_reason(&self) -> Option<&MessageParseError>
pub fn incomplete_reason(&self) -> Option<&MessageParseError>
Return what stopped the section walk, when it stopped early.
This is the error Message::parse_strict reports for the same
message, without a partial message of its own.
Trait Implementations§
impl Eq for Message
impl StructuralPartialEq for Message
Auto Trait Implementations§
impl Freeze for Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnsafeUnpin for Message
impl UnwindSafe for Message
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a rama_grpc::Request§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy that returns Action::Follow only if self and other return
Action::Follow. Read more