M Cargo.lock => Cargo.lock +16 -0
@@ 1,6 1,11 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
+name = "autocfg"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
name = "bitflags"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ 129,6 134,14 @@ dependencies = [
]
[[package]]
+name = "indexmap"
+version = "1.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
name = "iovec"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ 454,6 467,7 @@ version = "0.1.0"
dependencies = [
"bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "indexmap 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"mac_address 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"os_info 2.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"thiserror 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)",
@@ 473,6 487,7 @@ dependencies = [
]
[metadata]
+"checksum autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"
"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
"checksum bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "130aac562c0dd69c56b3b1cc8ffd2e17be31d0b6c25b61c96b76231aa23e39e1"
"checksum cc 1.0.54 (registry+https://github.com/rust-lang/crates.io-index)" = "7bbb73db36c1246e9034e307d0fba23f9a2e251faa47ade70c1bd252220c8311"
@@ 489,6 504,7 @@ dependencies = [
"checksum futures-task 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "bdb66b5f09e22019b1ab0830f7785bcea8e7a42148683f99214f73f8ec21a626"
"checksum futures-util 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8764574ff08b701a084482c3c7031349104b07ac897393010494beaa18ce32c6"
"checksum hermit-abi 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "91780f809e750b0a89f5544be56617ff6b1227ee485bcb06ebe10cdf89bd3b71"
+"checksum indexmap 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "076f042c5b7b98f31d205f1249267e12a6518c1481e9dae9764af19b707d2292"
"checksum iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e"
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
M yooper/Cargo.toml => yooper/Cargo.toml +1 -0
@@ 8,6 8,7 @@ edition = "2018"
bytes = "0.5.4"
yooper_derive = { path = "../yooper_derive" }
futures = "0.3"
+indexmap = "1.3"
mac_address = "1.0"
thiserror = "1.0"
os_info = "2.0"
M yooper/src/main.rs => yooper/src/main.rs +5 -5
@@ 1,7 1,7 @@
-use std::error::Error;
-use std::net::Ipv4Addr;
-
-use yooper::discovery::Discovery;
+use yooper::{
+ Error,
+ discovery::Discovery
+};
// const VERSION: &'static str = env!("CARGO_PKG_VERSION");
// const OS: &'static str = "linux"; //TODO
@@ 16,7 16,7 @@ use yooper::discovery::Discovery;
// CPUUID.UPNP.ORG: uuid of the control point
#[tokio::main]
-async fn main() -> Result<(), Box<dyn Error>> {
+async fn main() -> Result<(), Error> {
let mut discovery = Discovery::new().await?;
for result in discovery.find(5).await? {
M yooper/src/ssdp/packet.rs => yooper/src/ssdp/packet.rs +2 -2
@@ 1,7 1,7 @@
mod decoder;
mod encoder;
-use std::collections::HashMap;
+use indexmap::IndexMap;
use std::net::Ipv4Addr;
use std::str::FromStr;
@@ 49,7 49,7 @@ impl FromStr for PacketType {
}
}
-pub type Headers = HashMap<String, String>;
+pub type Headers = IndexMap<String, String>;
#[derive(PartialEq, Debug)]
pub struct Packet {
M yooper/src/ssdp/packet/decoder.rs => yooper/src/ssdp/packet/decoder.rs +2 -3
@@ 1,9 1,8 @@
use crate::errors::Error;
use bytes::BytesMut;
-use std::collections::HashMap;
use tokio_util::codec;
-use super::Packet;
+use super::{Packet, Headers};
#[derive(Default)]
pub struct Decoder {}
@@ 27,7 26,7 @@ impl codec::Decoder for Decoder {
let typ = reqline.parse()?;
- let headers: HashMap<String, String> =
+ let headers: Headers =
iter.map(split_header).collect::<Result<_, Error>>()?;
Ok(Some(Packet { typ, headers }))
M yooper_derive/src/to_packet.rs => yooper_derive/src/to_packet.rs +1 -1
@@ 87,7 87,7 @@ impl<'a> ToTokens for ToHeaders<'a> {
let fields = self.0.fields.iter().map(VariantMember::to_message);
tokens.extend(quote! {
- let mut headers = std::collections::HashMap::new();
+ let mut headers = crate::ssdp::packet::Headers::new();
#(#fields)*
headers
})