clarify the iterators in the Lookup Types

This commit is contained in:
Benjamin Fry 2024-01-04 20:44:55 -08:00
parent 642d33ca71
commit 2cdfab9bf0
2 changed files with 10 additions and 5 deletions

View File

@ -84,12 +84,14 @@ impl Lookup {
&self.query
}
/// Returns a borrowed iterator of the returned IPs
/// Returns an iterator over the matching the queried record type.
pub fn iter(&self) -> LookupIter<'_> {
LookupIter(self.records.iter())
}
/// Returns a borrowed iterator of the returned IPs
/// Returns an iterator over all records returned during the query.
///
/// It may include additional record types beyond the queried type, e.g. CNAME.
pub fn record_iter(&self) -> LookupRecordIter<'_> {
LookupRecordIter(self.records.iter())
}
@ -108,7 +110,8 @@ impl Lookup {
self.records.len()
}
/// Returns the records list
/// Returns an slice over all records that were returned during the query, this can include
/// additional record types beyond the queried type, e.g. CNAME.
pub fn records(&self) -> &[Record] {
self.records.as_ref()
}
@ -400,7 +403,7 @@ macro_rules! lookup_type {
pub struct $l(Lookup);
impl $l {
/// Returns an iterator over the RData
#[doc = stringify!(Returns an iterator over the records that match $r)]
pub fn iter(&self) -> $i<'_> {
$i(self.0.iter())
}

View File

@ -36,7 +36,9 @@ use crate::lookup::{Lookup, LookupIntoIter, LookupIter};
pub struct LookupIp(Lookup);
impl LookupIp {
/// Returns a borrowed iterator of the returned IPs
/// Returns an iterator over the response records.
///
/// Only IP records will be returned, either A or AAAA record types.
pub fn iter(&self) -> LookupIpIter<'_> {
LookupIpIter(self.0.iter())
}