You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use type_uuid::{TypeUuid};use cglue::*;#[cglue_trait]pubtraitUUIDIdentifiable{fnuuid(&self) -> UUID;}impl<T:TypeUuid>UUIDIdentifiableforT{fnuuid(&self) -> UUID{UUID{value: <SelfasTypeUuid>::UUID}}}#[repr(C)]#[derive(Debug,Clone,Copy)]pubstructUUID{value:[u8;16],}#[repr(C)]#[derive(TypeUuid)]#[uuid = "d4adfc76-f5f4-40b0-8e28-8a51a12f5e46"]pubstructMyType;
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> UUIDIdentifiableforT{
| ---------------------------------------- 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:
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
The text was updated successfully, but these errors were encountered:
I had a crack at this, and I think I figured out a way to work around this on CGlue's side:
#[repr(C)]structCGlue<T>(pubT);impl<T:GetVtbl<MagicVtbl<()>>>MagicforCGlue<T>{fnmagic(&self){let v = self.0.get_vtbl();let p = self.0.get_obj();(v.magic)(p)}}impl<T:Magic>Magicfor&T{fnmagic(&self){T::magic(*self)}}
Background:
Currently, cglue codegen spits out implementation for CGlueO, which conflicts with any blanket impl. I did this for a generic, instead of CGlueObj<...>, because I needed to support arbitrary trait_group! objects. However, in both cases I can wrap around a shared object, like CGlue<T>, which can then limit the generic impl to just cglue objects. Should be in for 0.4.
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
The text was updated successfully, but these errors were encountered: