Clone
1
Refactor bluetooth support student project
Josh Matthews edited this page 2019-02-13 20:15:35 -05:00

Refactor bluetooth support with more interfaces

Background information: The WebBluetooth specification allows websites to interact with active bluetooth devices in the vicinity of a user. Servo is a new, experimental browser that implements this specification; since bluetooth support requires lots of per-platform code, the current implementation is messy. The goal of this project is to implement clean separation of a cross-platform interface from the specific per-platform implementation to make the code more maintainable.

Tracking issue: (please ask questions in these issues)

Useful references:

  • Setup for making changes to Servo's code
  • The per-platform Bluetooth backend implementation
  • The cross-platform Servo bluetooth integration
  • Documentation for integrating a version of the devices library that contains your local changes into your local Servo build
  • Traits and other useful Rust documentation

Initial steps:

  • email the mozilla.dev.servo mailing list (be sure to subscribe to it first!) introducing your group and asking any necessary questions
  • Convert the BluetoothAdapter type from an enum to a trait. Create a new adapter.rs file (and therefore module) that contains implementations of this new trait for all platforms.
  • Modify Servo's integration to use this new trait, replacing uses of the old BluetoothAdapter enum with a trait object.
  • Convert the BluetoothDiscoverySession type from an enum to a trait. Create a new discovery_session.rs file that contains implementations of this new trait for all platforms.
  • Modify Servo's integration to use this new trait, replacing uses of the old BluetoothDiscoverySession enum with a trait object.

Subsequent steps:

  • Convert the remaining enums in the devices crate to traits and update the Servo implementation to use these. The result should be much easier to read code in both projects.