QueryParam

Struct QueryParam 

Source
pub struct QueryParam<'a> { /* private fields */ }
Expand description

How a lookup is performed.

Implementations§

Source§

impl<'a> QueryParam<'a>

Source

pub fn new(service: Label<'a>) -> Self

Creates a new query parameter with default values.

Source

pub fn with_domain(self, domain: Label<'a>) -> Self

Sets the domain to search in.

§Example
use agnostic_mdns::QueryParam;

let params = QueryParam::new("service._tcp".into())
  .with_domain("local.".into());
Source

pub const fn domain(&self) -> &Label<'a>

Returns the domain to search in.

§Example
use agnostic_mdns::{QueryParam, Label};

let params = QueryParam::new("service._tcp".into())
  .with_domain("local.".into());

assert_eq!(params.domain(), &Label::from("local"));
Source

pub fn with_service(self, service: Label<'a>) -> Self

Sets the service to search for.

§Example
use agnostic_mdns::QueryParam;

let params = QueryParam::new("service._tcp".into())
  .with_service("service._udp".into());
Source

pub const fn service(&self) -> &Label<'a>

Returns the service to search for.

§Example
use agnostic_mdns::{QueryParam, Label};

let params = QueryParam::new("service._tcp".into())
  .with_service("service._udp".into());

assert_eq!(params.service(), &Label::from("service._udp"));
Source

pub fn with_timeout(self, timeout: Duration) -> Self

Sets the timeout for the query.

§Example
use agnostic_mdns::QueryParam;

let params = QueryParam::new("service._tcp".into())
  .with_timeout(std::time::Duration::from_secs(1));
Source

pub const fn timeout(&self) -> Duration

Returns the timeout for the query.

§Example
use agnostic_mdns::QueryParam;

let params = QueryParam::new("service._tcp".into())
  .with_timeout(std::time::Duration::from_secs(1));

assert_eq!(params.timeout(), std::time::Duration::from_secs(1));
Source

pub fn with_ipv4_interface(self, ipv4_interface: Ipv4Addr) -> Self

Sets the IPv4 interface to use for queries.

§Example
use agnostic_mdns::QueryParam;

let params = QueryParam::new("service._tcp".into())
  .with_ipv4_interface("0.0.0.0".parse().unwrap());
Source

pub const fn ipv4_interface(&self) -> Option<&Ipv4Addr>

Returns the IPv4 interface to use for queries.

§Example
use agnostic_mdns::QueryParam;

let params = QueryParam::new("service._tcp".into())
 .with_ipv4_interface("0.0.0.0".parse().unwrap());

assert_eq!(params.ipv4_interface().unwrap(), &"0.0.0.0".parse::<std::net::Ipv4Addr>().unwrap());
Source

pub fn with_ipv6_interface(self, ipv6_interface: u32) -> Self

Sets the IPv6 interface to use for queries.

§Example
use agnostic_mdns::QueryParam;

let params = QueryParam::new("service._tcp".into())
  .with_ipv6_interface(1);
Source

pub const fn ipv6_interface(&self) -> Option<u32>

Returns the IPv6 interface to use for queries.

§Example
use agnostic_mdns::QueryParam;

let params = QueryParam::new("service._tcp".into())
  .with_ipv6_interface(1);
assert_eq!(params.ipv6_interface().unwrap(), 1);
Source

pub fn with_unicast_response(self, want_unicast_response: bool) -> Self

Sets whether to request unicast responses.

§Example
use agnostic_mdns::QueryParam;

let params = QueryParam::new("service._tcp".into())
  .with_unicast_response(true);
Source

pub const fn want_unicast_response(&self) -> bool

Returns whether to request unicast responses.

§Example
use agnostic_mdns::QueryParam;

let params = QueryParam::new("service._tcp".into())
  .with_unicast_response(true);

assert_eq!(params.want_unicast_response(), true);
Source

pub fn with_disable_ipv4(self, disable_ipv4: bool) -> Self

Sets whether to disable IPv4 for MDNS operations.

§Example
use agnostic_mdns::QueryParam;

let params = QueryParam::new("service._tcp".into())
  .with_disable_ipv4(true);
Source

pub const fn disable_ipv4(&self) -> bool

Returns whether to disable IPv4 for MDNS operations.

§Example
use agnostic_mdns::QueryParam;

let params = QueryParam::new("service._tcp".into())
  .with_disable_ipv4(true);

assert_eq!(params.disable_ipv4(), true);
Source

pub fn with_disable_ipv6(self, disable_ipv6: bool) -> Self

Sets whether to disable IPv6 for MDNS operations.

§Example
use agnostic_mdns::QueryParam;

let params = QueryParam::new("service._tcp".into())
  .with_disable_ipv6(true);
Source

pub const fn disable_ipv6(&self) -> bool

Returns whether to disable IPv6 for MDNS operations.

§Example
use agnostic_mdns::QueryParam;

let params = QueryParam::new("service._tcp".into())
  .with_disable_ipv6(true);

assert_eq!(params.disable_ipv6(), true);
Source

pub const fn max_payload_size(&self) -> usize

Returns the configured maximum payload size for mDNS message packets.

This value limits how large each mDNS packet can be when sending queries or receiving responses.

Smaller values may be necessary on networks with MTU constraints or when working with devices that have limited buffer sizes.

Default is 1500 bytes.

§Example
use agnostic_mdns::QueryParam;

let params = QueryParam::new("service._tcp".into())
 .with_max_payload_size(1500);
Source

pub const fn with_max_payload_size(self, max_payload_size: usize) -> Self

Sets the maximum payload size for mDNS message packets.

This controls how large each mDNS packet can be when sending queries or receiving responses.

You might want to adjust this value to:

  • Reduce the size to avoid IP fragmentation on networks with lower MTUs
  • Match device-specific constraints in IoT environments
  • Optimize for specific network conditions

Default is 1500 bytes.

§Example
use agnostic_mdns::QueryParam;

let params = QueryParam::new("service._tcp".into())
.with_max_payload_size(1500);

assert_eq!(params.max_payload_size(), 1500);
Source

pub const fn capacity(&self) -> Option<usize>

Returns the channel capacity for the [Lookup] stream.

If None, the channel is unbounded.

Default is None.

§Example
use agnostic_mdns::QueryParam;

let params = QueryParam::new("service._tcp".into())
  .with_capacity(Some(10));

assert_eq!(params.capacity().unwrap(), 10);
Source

pub fn with_capacity(self, cap: Option<usize>) -> Self

Sets the channel capacity for the [Lookup] stream.

If None, the channel is unbounded.

Default is None.

§Example
use agnostic_mdns::QueryParam;

let params = QueryParam::new("service._tcp".into())
 .with_capacity(Some(10));

Trait Implementations§

Source§

impl<'a> Clone for QueryParam<'a>

Source§

fn clone(&self) -> QueryParam<'a>

Returns a duplicate 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<'a> Debug for QueryParam<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for QueryParam<'a>

§

impl<'a> RefUnwindSafe for QueryParam<'a>

§

impl<'a> Send for QueryParam<'a>

§

impl<'a> Sync for QueryParam<'a>

§

impl<'a> Unpin for QueryParam<'a>

§

impl<'a> UnwindSafe for QueryParam<'a>

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
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<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