Skip to content

Commit

Permalink
bump socket2 version (#174)
Browse files Browse the repository at this point in the history
* update rust version
* CI:update rust-toolchain version
* Clippy fixes
  • Loading branch information
irvingoujAtDevolution authored Mar 20, 2024
1 parent e6fa83b commit bccee8e
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 104 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
os: [ubuntu-20.04, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@1.61.0
- uses: dtolnay/rust-toolchain@1.63.0
with:
components: rustfmt, clippy
- name: Run rustfmt and fail if any warnings
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "mdns-sd"
version = "0.10.4"
authors = ["keepsimple <[email protected]>"]
edition = "2018"
rust-version = "1.61.0"
rust-version = "1.63.0"
license = "Apache-2.0 OR MIT"
repository = "https://github.com/keepsimple1/mdns-sd"
documentation = "https://docs.rs/mdns-sd"
Expand All @@ -21,7 +21,7 @@ flume = { version = "0.11", default-features = false } # channel between threads
if-addrs = { version = "0.10", features = ["link-local"] } # get local IP addresses
log = { version = "0.4", optional = true } # logging
polling = "2.1" # select/poll sockets
socket2 = { version = "0.4", features = ["all"] } # socket APIs
socket2 = { version = "0.5.5", features = ["all"] } # socket APIs

[dev-dependencies]
fastrand = "1.8"
2 changes: 1 addition & 1 deletion examples/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fn print_usage() {
println!("Usage: cargo run --example query <service_type_without_domain_postfix>");
println!("Example: ");
println!("cargo run --example query _my-service._udp");
println!("");
println!();
println!("You can also do a meta-query per RFC 6763 to find which services are available:");
println!("cargo run --example query _services._dns-sd._udp");
}
20 changes: 8 additions & 12 deletions examples/register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ fn main() {
let args: Vec<String> = env::args().collect();
let mut should_unreg = false;
for arg in args.iter() {
match arg.as_str() {
"--unregister" => should_unreg = true,
_ => {}
if arg.as_str() == "--unregister" {
should_unreg = true
}
}

Expand Down Expand Up @@ -50,12 +49,12 @@ fn main() {

// The key string in TXT properties is case insensitive. Only the first
// (key, val) pair will take effect.
let properties = vec![("PATH", "one"), ("Path", "two"), ("PaTh", "three")];
let properties = [("PATH", "one"), ("Path", "two"), ("PaTh", "three")];

// Register a service.
let service_info = ServiceInfo::new(
&service_type,
&instance_name,
instance_name,
service_hostname,
my_addrs,
port,
Expand Down Expand Up @@ -85,12 +84,9 @@ fn main() {
// Monitor the daemon events.
while let Ok(event) = monitor.recv() {
println!("Daemon event: {:?}", &event);
match event {
DaemonEvent::Error(e) => {
println!("Failed: {}", e);
break;
}
_ => {}
if let DaemonEvent::Error(e) = event {
println!("Failed: {}", e);
break;
}
}
}
Expand All @@ -101,7 +97,7 @@ fn print_usage() {
println!("cargo run --example register <service_type> <instance_name> [--unregister]");
println!("Options:");
println!("--unregister: automatically unregister after 2 seconds");
println!("");
println!();
println!("For example:");
println!("cargo run --example register _my-hello._udp test1");
}
8 changes: 4 additions & 4 deletions src/service_daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ pub enum UnregisterStatus {
}

/// Status code for the service daemon.
#[derive(Debug, PartialEq, Clone)]
#[derive(Debug, PartialEq, Clone, Eq)]
#[non_exhaustive]
pub enum DaemonStatus {
/// The daemon is running as normal.
Expand Down Expand Up @@ -2314,9 +2314,9 @@ mod tests {

#[test]
fn test_instance_name() {
assert_eq!(valid_instance_name("my-laser._printer._tcp.local."), true);
assert_eq!(valid_instance_name("my-laser.._printer._tcp.local."), true);
assert_eq!(valid_instance_name("_printer._tcp.local."), false);
assert!(valid_instance_name("my-laser._printer._tcp.local."));
assert!(valid_instance_name("my-laser.._printer._tcp.local."));
assert!(!valid_instance_name("_printer._tcp.local."));
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/service_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ mod tests {

// test decode
let decoded = decode_txt(&encoded);
assert!(&properties[..] == &decoded[..]);
assert!(properties[..] == decoded[..]);

// test empty value
let properties = vec![TxtProperty::from(&("key3", ""))];
Expand Down
4 changes: 2 additions & 2 deletions tests/addr_parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn test_addr_str() {

// verify that `&String` also works.
assert_eq!(
(&addr).as_ip_addrs(),
addr.as_ip_addrs(),
Ok({
let mut set = HashSet::new();
set.insert(Ipv4Addr::new(127, 0, 0, 1).into());
Expand Down Expand Up @@ -134,7 +134,7 @@ fn test_addr_ip() {
);

assert_eq!(
(&ip).as_ip_addrs(),
ip.as_ip_addrs(),
Ok({
let mut set = HashSet::new();
set.insert(Ipv4Addr::new(127, 0, 0, 1).into());
Expand Down
Loading

0 comments on commit bccee8e

Please sign in to comment.