• Stars
    star
    113
  • Rank 310,115 (Top 7 %)
  • Language
    Rust
  • License
    MIT License
  • Created almost 8 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A multicast DNS client in Rust

mdns

Build Status crates.io MIT license

Documentation

An multicast DNS client in Rust.

Error logging is handled with the log library.

Wikipedia

Example

Find IP addresses for all Chromecasts on the local network.

use futures_util::{pin_mut, stream::StreamExt};
use mdns::{Error, Record, RecordKind};
use std::{net::IpAddr, time::Duration};


const SERVICE_NAME: &'static str = "_googlecast._tcp.local";

#[async_std::main]
async fn main() -> Result<(), Error> {
    // Iterate through responses from each Cast device, asking for new devices every 15s
    let stream = mdns::discover::all(SERVICE_NAME, Duration::from_secs(15))?.listen();
    pin_mut!(stream);

    while let Some(Ok(response)) = stream.next().await {
        let addr = response.records()
                           .filter_map(self::to_ip_addr)
                           .next();

        if let Some(addr) = addr {
            println!("found cast device at {}", addr);
        } else {
            println!("cast device does not advertise address");
        }
    }

    Ok(())
}

fn to_ip_addr(record: &Record) -> Option<IpAddr> {
    match record.kind {
        RecordKind::A(addr) => Some(addr.into()),
        RecordKind::AAAA(addr) => Some(addr.into()),
        _ => None,
    }
}

More Repositories

1

protocol

Easy protocol definitions in Rust
Rust
181
star
2

avr

An AVR emulator
Rust
16
star
3

lit

An integrated testing tool inspired from LLVM's 'lit' tool
Rust
15
star
4

ib-rs

A Rust client to the Interactive Brokers HTTP REST API
Rust
15
star
5

psvr-protocol

Breakdown of the PlayStation VR communication protocols for programmers
12
star
6

javabc

Java bytecode library in Rust
Rust
11
star
7

compiler

A [not-really-working] compiler from the ground-up
Rust
11
star
8

polk

A dotfile manager and symlinker
Rust
9
star
9

gcast

A Rust library for communicating with Google Cast devices
Rust
7
star
10

rurust

Run a Ruby VM from Rust
Rust
7
star
11

simavr-sim

High level Rust bindings to the simavr AVR simulator
Rust
6
star
12

rubic

A Ruby parser
Rust
5
star
13

flep

A FTP server implementation in Rust
Rust
5
star
14

simavr-sys

Low level Rust bindings to the simavr AVR simulator
Rust
3
star
15

mri-sys

Rust bindings to Mat'z Ruby Interpreter
Rust
3
star
16

avr-compiler-integration-tests

AVR compiler test suite
Rust
3
star
17

small_basic_compiler

Microsoft Small Basic LLVM Frontend
C++
3
star
18

delay

[NOTE: Moved to avr-rust/delay] Compile-time delays for Rust on AVR
Rust
2
star
19

xproto

Rust bindings to the X11 protocol library
Rust
2
star
20

hllvm

LLVM bindings for Rust
Rust
2
star
21

vsprintf

Rust bindings to the libc 'vsprintf' function
Rust
1
star
22

mash

3D mesh manipulation library
Rust
1
star
23

llvm.vim

LLVM Vim plugin directly from upstream LLVM
Vim Script
1
star
24

plugger

Plug Rust directly into a Ruby VM
Rust
1
star
25

hmdee

A Rust library for interfacing with the PlayStation VR
Rust
1
star
26

parapet

Peer to peer build system
Rust
1
star
27

minecraft

A Minecraft client written in Rust
Rust
1
star
28

clang-avr-libc-interrupt-example

An example that uses AVR-clang to define interrupt handlers that work with the AVR-GCC CRT runtime libraries
C
1
star
29

rphys

A physics simulation in Ruby
Ruby
1
star
30

c-parser

An [very imcomplete] C parser in Rust
Rust
1
star
31

target-cpu-utils

A Rust library and associated macros for querying the target CPU from the active target specification JSON
Rust
1
star
32

engine

A 3D game engine written in Rust
Rust
1
star