Struct simple_mdns::SimpleMdnsResponder[][src]

pub struct SimpleMdnsResponder { /* fields omitted */ }
Expand description

A simple mDNS responder aimed for service discovery. In case you don’t have a mDNS responder in your network, or for some reason don’t want to use the ones available.

This responder will list for any mDNS query in the network via Multicast and will reply only to the resources that were added.

    use simple_mdns::SimpleMdnsResponder;
    use simple_dns::{Name, CLASS, ResourceRecord, rdata::{RData, A, SRV}};
    use std::net::Ipv4Addr;


    let mut responder = SimpleMdnsResponder::new(10, true);
    let srv_name = Name::new_unchecked("_srvname._tcp.local");

    responder.add_resource(ResourceRecord {
        class: CLASS::IN,
        name: srv_name.clone(),
        ttl: 10,
        rdata: RData::A(A { address: Ipv4Addr::LOCALHOST.into() }),
    });

    responder.add_resource(ResourceRecord {
        class: CLASS::IN,
        name: srv_name.clone(),
        ttl: 10,
        rdata: RData::SRV(Box::new(SRV {
            port: 8080,
            priority: 0,
            weight: 0,
            target: srv_name
        }))
    });

This struct heavily relies on simple_dns crate and the same must be added as a dependency

Implementations

Creates a new SimpleMdnsResponder with ttl of 5 minutes and enabled loopback

Register a Resource Record

Remove a resource record

Remove all resource records

Set the simple mdns responder’s enable loopback.

Set the simple mdns responder’s rr default ttl in seconds (defaults to 300).

Trait Implementations

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.