fuchsia_bluetooth/
types.rsuse fidl_fuchsia_bluetooth_sys as sys;
use std::fmt;
mod address;
pub use address::*;
pub mod bonding_data;
pub use bonding_data::*;
mod channel;
pub use channel::*;
pub mod host_info;
pub use host_info::*;
mod id;
pub use id::*;
pub mod io_capabilities;
pub mod le;
pub mod pairing_options;
mod peer;
pub use peer::*;
mod uuid;
pub use uuid::*;
macro_rules! bt_fidl_wrap {
($outer:ident) => {
pub struct $outer(fidl_fuchsia_bluetooth::$outer);
impl From<fidl_fuchsia_bluetooth::$outer> for $outer {
fn from(b: fidl_fuchsia_bluetooth::$outer) -> $outer {
$outer(b)
}
}
impl Into<fidl_fuchsia_bluetooth::$outer> for $outer {
fn into(self) -> fidl_fuchsia_bluetooth::$outer {
self.0
}
}
};
}
bt_fidl_wrap!(Status);
bt_fidl_wrap!(Bool);
bt_fidl_wrap!(Int8);
bt_fidl_wrap!(UInt16);
impl fmt::Display for Bool {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(fmt, "{}", self.0.value)
}
}
impl fmt::Display for Status {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(fmt, "{:?}", self.0.error)
}
}
#[derive(Clone, Debug, PartialEq)]
pub enum OneOrBoth<L, R> {
Left(L),
Both(L, R),
Right(R),
}
impl<L, R> OneOrBoth<L, R> {
pub fn left(&self) -> Option<&L> {
match &self {
OneOrBoth::Left(l) => Some(l),
OneOrBoth::Both(l, _) => Some(l),
OneOrBoth::Right(_) => None,
}
}
pub fn right(&self) -> Option<&R> {
match &self {
OneOrBoth::Left(_) => None,
OneOrBoth::Both(_, r) => Some(r),
OneOrBoth::Right(r) => Some(r),
}
}
}
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum Technology {
LE,
Classic,
DualMode,
}
impl From<sys::TechnologyType> for Technology {
fn from(tech: sys::TechnologyType) -> Self {
match tech {
sys::TechnologyType::LowEnergy => Technology::LE,
sys::TechnologyType::Classic => Technology::Classic,
sys::TechnologyType::DualMode => Technology::DualMode,
}
}
}
impl From<Technology> for sys::TechnologyType {
fn from(tech: Technology) -> Self {
match tech {
Technology::LE => sys::TechnologyType::LowEnergy,
Technology::Classic => sys::TechnologyType::Classic,
Technology::DualMode => sys::TechnologyType::DualMode,
}
}
}