easy_bluez/
lib.rs

1extern crate basic_scheduler;
2extern crate blurz;
3#[macro_use]
4extern crate error_chain;
5extern crate eui48;
6#[macro_use]
7extern crate log;
8extern crate mvdb;
9#[macro_use]
10extern crate serde_derive;
11extern crate uuid;
12
13pub mod errors;
14mod bt_manager;
15mod api;
16
17pub use api::*;
18pub use basic_scheduler::Duration;
19pub use uuid::Uuid;
20
21use std::hash::{Hash, Hasher};
22use std::str::FromStr;
23
24use errors::*;
25use eui48::MacAddress;
26
27impl Hash for BtMacAddress {
28    fn hash<H: Hasher>(&self, state: &mut H) {
29        self.0.as_bytes().hash(state)
30    }
31}
32
33impl From<MacAddress> for BtMacAddress {
34    fn from(other: MacAddress) -> Self {
35        BtMacAddress(other)
36    }
37}
38
39impl FromStr for BtMacAddress {
40    type Err = Error;
41    /// Create a MacAddress from String
42    fn from_str(us: &str) -> Result<BtMacAddress> {
43        Ok(Self {
44            0: MacAddress::parse_str(us).chain_err(|| "Not a MAC address!")?,
45        })
46    }
47}
48
49
50#[derive(Clone, Deserialize, Serialize, Debug, PartialEq, Eq)]
51pub struct BtMacAddress(MacAddress);