mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Rewrite From/TryFrom conversions on generated types to avoid future orphan rule violations (#34554)
* script: Add traits to allow converting between types that are not defined in the script crate. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Rewrite all From/TryFrom implementations on generated WebIDL types to use new Convert/TryConvert traits. Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
parent
e10e989abb
commit
e0cbab2fbb
40 changed files with 439 additions and 380 deletions
|
@ -8,6 +8,7 @@ use bluetooth_traits::blocklist::{Blocklist, uuid_is_blocklisted};
|
|||
use bluetooth_traits::scanfilter::{BluetoothScanfilter, BluetoothScanfilterSequence};
|
||||
use bluetooth_traits::scanfilter::{RequestDeviceoptions, ServiceUUIDSequence};
|
||||
use crate::realms::{AlreadyInRealm, InRealm};
|
||||
use crate::conversions::Convert;
|
||||
use crate::dom::bindings::cell::{DomRefCell, Ref};
|
||||
use crate::dom::bindings::codegen::Bindings::BluetoothBinding::BluetoothDataFilterInit;
|
||||
use crate::dom::bindings::codegen::Bindings::BluetoothBinding::{BluetoothMethods, RequestDeviceOptions};
|
||||
|
@ -130,7 +131,7 @@ where
|
|||
.handle_response(response, &promise, can_gc),
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetooth-requestdevice
|
||||
// Step 3 - 4.
|
||||
Err(error) => promise.reject_error(Error::from(error)),
|
||||
Err(error) => promise.reject_error(error.convert()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -521,9 +522,9 @@ fn canonicalize_bluetooth_data_filter_init(
|
|||
Ok((data_prefix, mask))
|
||||
}
|
||||
|
||||
impl From<BluetoothError> for Error {
|
||||
fn from(error: BluetoothError) -> Self {
|
||||
match error {
|
||||
impl Convert<Error> for BluetoothError {
|
||||
fn convert(self) -> Error {
|
||||
match self {
|
||||
BluetoothError::Type(message) => Error::Type(message),
|
||||
BluetoothError::Network => Error::Network,
|
||||
BluetoothError::NotFound => Error::NotFound,
|
||||
|
@ -706,7 +707,7 @@ impl PermissionAlgorithm for Bluetooth {
|
|||
match receiver.recv().unwrap() {
|
||||
Ok(true) => (),
|
||||
Ok(false) => continue,
|
||||
Err(error) => return promise.reject_error(Error::from(error)),
|
||||
Err(error) => return promise.reject_error(error.convert()),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue