summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <matthias.beyer@ifm.com>2022-08-01 09:05:45 +0200
committerMatthias Beyer <matthias.beyer@ifm.com>2022-08-30 13:54:49 +0200
commit82e19c2cd5f4502a1ae9fffc392d18e7724da1b7 (patch)
tree730b4a5f7e59144eba71b4740f3fa8b3b21d97d4
parent8de9b80b8c5f596cd4f03c36fbd00f0cc8ac543b (diff)
Revert "Vendor bevy_reflect fn for TypeUuids in generics"
As the comment on the vendored code said, this was vendored because the bevy_reflect crate got this functionality removed in 0.7.0, because of some issues with its implementation. In commit 3d36ec41dcbfe7d5ead2a9dc5777c933f7f37e09 ("re-enable #[derive(TypeUuid)] for generics (#4118)") of bevy_reflect, this issue was resolved. This commit was included in bevy_reflect 0.8.0, thus revert the patch. This reverts commit f5983e1f4a02b445f40378b87d4f7a37ed78ed41. Signed-off-by: Matthias Beyer <matthias.beyer@ifm.com>
-rw-r--r--crates/core/tedge_api/src/lib.rs2
-rw-r--r--crates/core/tedge_api/src/util.rs36
2 files changed, 0 insertions, 38 deletions
diff --git a/crates/core/tedge_api/src/lib.rs b/crates/core/tedge_api/src/lib.rs
index 14c00b02..a4f63087 100644
--- a/crates/core/tedge_api/src/lib.rs
+++ b/crates/core/tedge_api/src/lib.rs
@@ -33,8 +33,6 @@ pub use tokio_util::sync::CancellationToken;
/// Derive macro for self-describing configurations
pub use tedge_config_derive::Config;
-pub mod util;
-
#[doc(hidden)]
pub mod _internal {
pub use futures::future::BoxFuture;
diff --git a/crates/core/tedge_api/src/util.rs b/crates/core/tedge_api/src/util.rs
deleted file mode 100644
index ebd0fbf1..00000000
--- a/crates/core/tedge_api/src/util.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-//! Utilities
-
-/// Generates a new UUID from the given UUIDs `a` and `b`,
-/// where the bytes are generated by a bitwise `a ^ b.rotate_right(1)`.
-/// The generated UUID will be a `UUIDv4` (meaning that the bytes should be random, not e.g. derived from the system time).
-///
-/// # Note
-///
-/// Vendored from https://github.com/bevyengine/bevy/commit/3d36ec41dcbfe7d5ead2a9dc5777c933f7f37e09
-/// because the change was not released at the time of implementing the TypeUuid functionality.
-///
-/// Should be removed as soon as bevy_reflect 0.8.0 is released
-#[allow(clippy::unusual_byte_groupings)] // unusual byte grouping is meant to signal the relevant bits
-pub const fn generate_composite_uuid(
- a: bevy_reflect::Uuid,
- b: bevy_reflect::Uuid,
-) -> bevy_reflect::Uuid {
- let mut new = [0; 16];
- let mut i = 0;
- while i < new.len() {
- // rotating ensures different uuids for A<B<C>> and B<A<C>> because: A ^ (B ^ C) = B ^ (A ^ C)
- // notice that you have to rotate the second parameter: A.rr ^ (B.rr ^ C) = B.rr ^ (A.rr ^ C)
- // Solution: A ^ (B ^ C.rr).rr != B ^ (A ^ C.rr).rr
- new[i] = a.as_bytes()[i] ^ b.as_bytes()[i].rotate_right(1);
-
- i += 1;
- }
-
- // Version: the most significant 4 bits in the 6th byte: 11110000
- new[6] = new[6] & 0b0000_1111 | 0b0100_0000; // set version to v4
-
- // Variant: the most significant 3 bits in the 8th byte: 11100000
- new[8] = new[8] & 0b000_11111 | 0b100_00000; // set variant to rfc4122
-
- bevy_reflect::Uuid::from_bytes(new)
-}