Brian Silverman | 1059993 | 2022-08-15 06:05:53 -0700 | [diff] [blame^] | 1 | autocxx::include_cpp! ( |
| 2 | #include "aos/uuid.h" |
| 3 | #include "aos/uuid_for_rust.h" |
| 4 | |
| 5 | safety!(unsafe) |
| 6 | |
| 7 | generate_pod!("aos::UUID") |
| 8 | ); |
| 9 | |
| 10 | pub use ffi::aos::UUID; |
| 11 | |
| 12 | impl From<UUID> for uuid::Uuid { |
| 13 | fn from(uuid: UUID) -> uuid::Uuid { |
| 14 | uuid::Uuid::from_bytes(uuid.data) |
| 15 | } |
| 16 | } |
| 17 | |
| 18 | impl AsRef<uuid::Uuid> for UUID { |
| 19 | fn as_ref(&self) -> &uuid::Uuid { |
| 20 | uuid::Uuid::from_bytes_ref(&self.data) |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | impl From<uuid::Uuid> for UUID { |
| 25 | fn from(uuid: uuid::Uuid) -> UUID { |
| 26 | UUID { |
| 27 | data: *uuid.as_bytes(), |
| 28 | } |
| 29 | } |
| 30 | } |