Skip to main content

bt_common/
lib.rs

1// Copyright 2023 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5extern crate core as rust_core;
6
7/// Peers are identified by ids, which should be treated as opaque by service
8/// libraries. Stack implementations should ensure that each PeerId identifies a
9/// single peer over a single instance of the stack - a
10/// [`bt_gatt::Central::connect`] should always attempt to connect to the
11/// same peer as long as the PeerId was retrieved after the `Central` was
12/// instantiated. PeerIds can be valid longer than that (often if the peer is
13/// bonded)
14#[derive(Clone, Copy, PartialEq, Eq, Hash)]
15pub struct PeerId(pub u64);
16
17impl rust_core::fmt::Display for PeerId {
18    fn fmt(
19        &self,
20        f: &mut rust_core::fmt::Formatter<'_>,
21    ) -> std::result::Result<(), std::fmt::Error> {
22        write!(f, "{:016x}", self.0)
23    }
24}
25
26impl std::fmt::Debug for PeerId {
27    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
28        f.debug_tuple("PeerId").field(&format_args!("0x{}", self)).finish()
29    }
30}
31
32pub mod core;
33
34pub mod company_id;
35pub use company_id::CompanyId;
36
37pub mod generic_audio;
38
39pub mod packet_encoding;
40
41pub mod uuids;
42pub use crate::uuids::Uuid;
43
44pub mod debug_command;