mirror of
https://github.com/google/bumble.git
synced 2026-05-05 03:28:02 +00:00
Port l2cap_bridge sample to Rust
- Added Rust wrappers where relevant - Edited a couple logs in python l2cap_bridge to be more symmetrical - Created cli subcommand for running the rustified l2cap bridge
This commit is contained in:
@@ -31,11 +31,11 @@ pub use pyo3_asyncio;
|
||||
pub mod assigned_numbers;
|
||||
pub mod core;
|
||||
pub mod device;
|
||||
|
||||
pub mod drivers;
|
||||
pub mod gatt_client;
|
||||
pub mod hci;
|
||||
pub mod host;
|
||||
pub mod l2cap;
|
||||
pub mod logging;
|
||||
pub mod profile;
|
||||
pub mod transport;
|
||||
@@ -71,6 +71,21 @@ impl PyObjectExt for PyObject {
|
||||
}
|
||||
}
|
||||
|
||||
/// Convenience extensions to [PyDict]
|
||||
pub trait PyDictExt {
|
||||
/// Set item in dict only if value is Some, otherwise do nothing.
|
||||
fn set_opt_item<K: ToPyObject, V: ToPyObject>(&self, key: K, value: Option<V>) -> PyResult<()>;
|
||||
}
|
||||
|
||||
impl PyDictExt for PyDict {
|
||||
fn set_opt_item<K: ToPyObject, V: ToPyObject>(&self, key: K, value: Option<V>) -> PyResult<()> {
|
||||
if let Some(value) = value {
|
||||
self.set_item(key, value)?
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// Wrapper to make Rust closures ([Fn] implementations) callable from Python.
|
||||
///
|
||||
/// The Python callable form returns a Python `None`.
|
||||
|
||||
Reference in New Issue
Block a user