forked from auracaster/bumble_mirror
Update pdl to 0.2.0
- Allows removing impl PartialEq for pdl Error
This commit is contained in:
19
rust/Cargo.lock
generated
19
rust/Cargo.lock
generated
@@ -200,6 +200,7 @@ dependencies = [
|
|||||||
"nom",
|
"nom",
|
||||||
"owo-colors",
|
"owo-colors",
|
||||||
"pdl-derive",
|
"pdl-derive",
|
||||||
|
"pdl-runtime",
|
||||||
"pyo3",
|
"pyo3",
|
||||||
"pyo3-asyncio",
|
"pyo3-asyncio",
|
||||||
"rand",
|
"rand",
|
||||||
@@ -1157,9 +1158,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pdl-compiler"
|
name = "pdl-compiler"
|
||||||
version = "0.1.7"
|
version = "0.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f99a9ac3d6a426c6fc0b85903a16d77bf148e20ddf755361f76e230d1b6d72cf"
|
checksum = "ee66995739fb9ddd9155767990a54aadd226ee32408a94f99f94883ff445ceba"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"argh",
|
"argh",
|
||||||
"codespan-reporting",
|
"codespan-reporting",
|
||||||
@@ -1176,9 +1177,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pdl-derive"
|
name = "pdl-derive"
|
||||||
version = "0.1.7"
|
version = "0.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8ad882bdd3b2584b42180b7a216bfccc7c05e714de2789ee25ea622c85064ef7"
|
checksum = "113e4a1215c407466b36d2c2f6a6318819d6b22ccdd3acb7bb35e27a68806034"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"codespan-reporting",
|
"codespan-reporting",
|
||||||
"pdl-compiler",
|
"pdl-compiler",
|
||||||
@@ -1188,6 +1189,16 @@ dependencies = [
|
|||||||
"termcolor",
|
"termcolor",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pdl-runtime"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2d36c2f9799613babe78eb5cd9a353d527daaba6c3d1f39a1175657a35790732"
|
||||||
|
dependencies = [
|
||||||
|
"bytes",
|
||||||
|
"thiserror",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "percent-encoding"
|
name = "percent-encoding"
|
||||||
version = "2.3.0"
|
version = "2.3.0"
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ itertools = "0.11.0"
|
|||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
thiserror = "1.0.41"
|
thiserror = "1.0.41"
|
||||||
bytes = "1.5.0"
|
bytes = "1.5.0"
|
||||||
pdl-derive = "0.1.7"
|
pdl-derive = "0.2.0"
|
||||||
|
pdl-runtime = "0.2.0"
|
||||||
|
|
||||||
# Dev tools
|
# Dev tools
|
||||||
file-header = { version = "0.1.2", optional = true }
|
file-header = { version = "0.1.2", optional = true }
|
||||||
|
|||||||
@@ -16,11 +16,13 @@ use bumble::wrapper::{
|
|||||||
controller::Controller,
|
controller::Controller,
|
||||||
device::Device,
|
device::Device,
|
||||||
drivers::rtk::DriverInfo,
|
drivers::rtk::DriverInfo,
|
||||||
hci::packets::{
|
hci::{
|
||||||
AddressType, Error, ErrorCode, ReadLocalVersionInformationBuilder,
|
packets::{
|
||||||
ReadLocalVersionInformationComplete,
|
AddressType, ErrorCode, ReadLocalVersionInformationBuilder,
|
||||||
|
ReadLocalVersionInformationComplete,
|
||||||
|
},
|
||||||
|
Address, Error,
|
||||||
},
|
},
|
||||||
hci::Address,
|
|
||||||
host::Host,
|
host::Host,
|
||||||
link::Link,
|
link::Link,
|
||||||
transport::Transport,
|
transport::Transport,
|
||||||
|
|||||||
@@ -12,7 +12,9 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
use crate::internal::hci::packets::{Acl, Command, Error, Event, Packet, Sco};
|
pub use pdl_runtime::{Error, Packet};
|
||||||
|
|
||||||
|
use crate::internal::hci::packets::{Acl, Command, Event, Sco};
|
||||||
use pdl_derive::pdl;
|
use pdl_derive::pdl;
|
||||||
|
|
||||||
#[allow(missing_docs, warnings, clippy::all)]
|
#[allow(missing_docs, warnings, clippy::all)]
|
||||||
@@ -81,87 +83,10 @@ pub(crate) enum PacketTypeParseError {
|
|||||||
actual: PacketType,
|
actual: PacketType,
|
||||||
},
|
},
|
||||||
#[error("Failed to parse packet after header: {error}")]
|
#[error("Failed to parse packet after header: {error}")]
|
||||||
PacketParse { error: packets::Error },
|
PacketParse { error: Error },
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: remove if/when PDL derives this for their Error enum (https://github.com/google/pdl/issues/71)
|
impl From<Error> for PacketTypeParseError {
|
||||||
impl PartialEq<Self> for packets::Error {
|
|
||||||
fn eq(&self, other: &Self) -> bool {
|
|
||||||
match (self, other) {
|
|
||||||
(Error::InvalidPacketError, Error::InvalidPacketError) => true,
|
|
||||||
(
|
|
||||||
Error::ConstraintOutOfBounds {
|
|
||||||
field: field1,
|
|
||||||
value: value1,
|
|
||||||
},
|
|
||||||
Error::ConstraintOutOfBounds {
|
|
||||||
field: field2,
|
|
||||||
value: value2,
|
|
||||||
},
|
|
||||||
) => field1 == field2 && value1 == value2,
|
|
||||||
(
|
|
||||||
Error::InvalidFixedValue {
|
|
||||||
expected: expected1,
|
|
||||||
actual: actual1,
|
|
||||||
},
|
|
||||||
Error::InvalidFixedValue {
|
|
||||||
expected: expected2,
|
|
||||||
actual: actual2,
|
|
||||||
},
|
|
||||||
) => expected1 == expected2 && actual1 == actual2,
|
|
||||||
(
|
|
||||||
Error::InvalidLengthError {
|
|
||||||
obj: obj1,
|
|
||||||
wanted: wanted1,
|
|
||||||
got: got1,
|
|
||||||
},
|
|
||||||
Error::InvalidLengthError {
|
|
||||||
obj: obj2,
|
|
||||||
wanted: wanted2,
|
|
||||||
got: got2,
|
|
||||||
},
|
|
||||||
) => obj1 == obj2 && wanted1 == wanted2 && got1 == got2,
|
|
||||||
(
|
|
||||||
Error::InvalidArraySize {
|
|
||||||
array: array1,
|
|
||||||
element: element1,
|
|
||||||
},
|
|
||||||
Error::InvalidArraySize {
|
|
||||||
array: array2,
|
|
||||||
element: element2,
|
|
||||||
},
|
|
||||||
) => array1 == array2 && element1 == element2,
|
|
||||||
(Error::ImpossibleStructError, Error::ImpossibleStructError) => true,
|
|
||||||
(
|
|
||||||
Error::InvalidEnumValueError {
|
|
||||||
obj: obj1,
|
|
||||||
field: field1,
|
|
||||||
value: value1,
|
|
||||||
type_: type_1,
|
|
||||||
},
|
|
||||||
Error::InvalidEnumValueError {
|
|
||||||
obj: obj2,
|
|
||||||
field: field2,
|
|
||||||
value: value2,
|
|
||||||
type_: type_2,
|
|
||||||
},
|
|
||||||
) => obj1 == obj2 && field1 == field2 && value1 == value2 && type_1 == type_2,
|
|
||||||
(
|
|
||||||
Error::InvalidChildError {
|
|
||||||
expected: expected1,
|
|
||||||
actual: actual1,
|
|
||||||
},
|
|
||||||
Error::InvalidChildError {
|
|
||||||
expected: expected2,
|
|
||||||
actual: actual2,
|
|
||||||
},
|
|
||||||
) => expected1 == expected2 && actual1 == actual2,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<packets::Error> for PacketTypeParseError {
|
|
||||||
fn from(error: Error) -> Self {
|
fn from(error: Error) -> Self {
|
||||||
Self::PacketParse { error }
|
Self::PacketParse { error }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,9 +13,9 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
use crate::internal::hci::{
|
use crate::internal::hci::{
|
||||||
packets::{self, Event, EventBuilder, EventCode, Packet, Sco},
|
packets::{Event, EventBuilder, EventCode, Sco},
|
||||||
parse_with_expected_packet_type, prepend_packet_type, PacketType, PacketTypeParseError,
|
parse_with_expected_packet_type, prepend_packet_type, Error, Packet, PacketType,
|
||||||
WithPacketType,
|
PacketTypeParseError, WithPacketType,
|
||||||
};
|
};
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ fn test_packet_roundtrip_with_type() {
|
|||||||
struct FakePacket;
|
struct FakePacket;
|
||||||
|
|
||||||
impl FakePacket {
|
impl FakePacket {
|
||||||
fn parse(_bytes: &[u8]) -> Result<Self, packets::Error> {
|
fn parse(_bytes: &[u8]) -> Result<Self, Error> {
|
||||||
Ok(Self)
|
Ok(Self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
//! HCI
|
//! HCI
|
||||||
|
|
||||||
pub use crate::internal::hci::packets;
|
pub use crate::internal::hci::{packets, Error, Packet};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
internal::hci::WithPacketType,
|
internal::hci::WithPacketType,
|
||||||
|
|||||||
Reference in New Issue
Block a user