This code:
use type_uuid::{TypeUuid};
use cglue::*;
#[cglue_trait]
pub trait UUIDIdentifiable {
fn uuid(&self) -> UUID;
}
impl<T: TypeUuid> UUIDIdentifiable for T {
fn uuid(&self) -> UUID {
UUID { value: <Self as TypeUuid>::UUID }
}
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct UUID {
value: [u8; 16],
}
#[repr(C)]
#[derive(TypeUuid)]
#[uuid = "d4adfc76-f5f4-40b0-8e28-8a51a12f5e46"]
pub struct MyType;
Is currently not able to compile:
Compiling vtable_uuid v0.1.0 (F:\rust\vtable_uuid)
error[E0119]: conflicting implementations of trait `UUIDIdentifiable`
--> src/main.rs:5:1
|
5 | #[cglue_trait]
| ^^^^^^^^^^^^^^ conflicting implementation
...
10 | impl<T: TypeUuid> UUIDIdentifiable for T {
| ---------------------------------------- first implementation here
|
= note: this error originates in the attribute macro `cglue_trait` (in Nightly builds, run with -Z macro-backtrace for more info)
For more information about this error, try `rustc --explain E0119`.
error: could not compile `vtable_uuid` (bin "vtable_uuid") due to 1 previous error
Indeed there is another blanket implementation that makes it not okay:
impl<
'cglue_a,
CGlueO: 'cglue_a + UUIDIdentifiableVtblGet<'cglue_a>
+ UUIDIdentifiableOpaqueObj<'cglue_a>
+ UUIDIdentifiableAssocBind<Assocs = ()>
+ ::cglue::trait_group::GetVtblBase<
UUIDIdentifiableVtbl<
'cglue_a,
<Self as ::cglue::trait_group::GetContainer>::ContType,
>,
>,
> UUIDIdentifiable for CGlueO {
#[inline(always)]
fn uuid(&self) -> UUID {
let __cglue_vfunc = self.get_vtbl().uuid;
let cont = self.ccont_ref();
let mut ret = __cglue_vfunc(cont);
ret
}
}
This feature would be very useful, so we can now attach UUID to a struct and then put them into a universal container for applications to search in runtime. This is adapted by Microsoft in their COM IPC mechanism with a vtable hack, and also UEFI implementation
This code:
Is currently not able to compile:
Indeed there is another blanket implementation that makes it not okay:
This feature would be very useful, so we can now attach UUID to a struct and then put them into a universal container for applications to search in runtime. This is adapted by Microsoft in their COM IPC mechanism with a vtable hack, and also UEFI implementation