pub struct SimpleMdnsResponder { /* private fields */ }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::sync_discovery::SimpleMdnsResponder;
use simple_dns::{Name, CLASS, ResourceRecord, rdata::{RData, A, SRV}};
use std::net::Ipv4Addr;
let mut responder = SimpleMdnsResponder::new(10);
let srv_name = Name::new_unchecked("_srvname._tcp.local");
responder.add_resource(ResourceRecord::new(
srv_name.clone(),
CLASS::IN,
10,
RData::A(A { address: Ipv4Addr::LOCALHOST.into() }),
));
responder.add_resource(ResourceRecord::new(
srv_name.clone(),
CLASS::IN,
10,
RData::SRV(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§
Source§impl SimpleMdnsResponder
impl SimpleMdnsResponder
Sourcepub fn new(rr_ttl: u32) -> Self
pub fn new(rr_ttl: u32) -> Self
Creates a new SimpleMdnsResponder with specified ttl and IPV4 scope with UNSPECIFIED Interface
Sourcepub fn new_with_scope(rr_ttl: u32, scope: NetworkScope) -> Self
pub fn new_with_scope(rr_ttl: u32, scope: NetworkScope) -> Self
Creates a new SimpleMdnsResponder with specified ttl and network scope
Sourcepub fn add_resource(&mut self, resource: ResourceRecord<'static>)
pub fn add_resource(&mut self, resource: ResourceRecord<'static>)
Register a Resource Record
Sourcepub fn remove_resource_record(&mut self, resource: ResourceRecord<'static>)
pub fn remove_resource_record(&mut self, resource: ResourceRecord<'static>)
Remove a resource record
Sourcepub fn set_rr_ttl(&mut self, rr_default_ttl: u32)
pub fn set_rr_ttl(&mut self, rr_default_ttl: u32)
Set the simple mdns responder’s rr default ttl in seconds (defaults to 300).
Trait Implementations§
Source§impl Debug for SimpleMdnsResponder
impl Debug for SimpleMdnsResponder
Auto Trait Implementations§
impl Freeze for SimpleMdnsResponder
impl RefUnwindSafe for SimpleMdnsResponder
impl Send for SimpleMdnsResponder
impl Sync for SimpleMdnsResponder
impl Unpin for SimpleMdnsResponder
impl UnsafeUnpin for SimpleMdnsResponder
impl UnwindSafe for SimpleMdnsResponder
Blanket Implementations§
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
Mutably borrows from an owned value. Read more