pub(crate) unsafe fn implement<I: Interface, F>(
        self,
        implementation: F,
        user_data: UserData,
    ) -> ProxyInner
    where
        F: FnMut(I::Event, I) + 'static,
        I: From<Proxy<I>>,
        I::Event: MessageGroup<Map = super::ProxyMap>,
    {
        let object = self.map.lock().unwrap().with(self.id, |obj| {
            obj.meta.dispatcher = super::make_dispatcher(implementation);
            obj.meta.user_data = Arc::new(user_data);
            obj.clone()
        });

        let object = match object {
            Ok(obj) => obj,
            Err(()) => {
                // We are trying to implement a non-existent object
                // This is either a bug in the lib (a NewProxy was created while it should not
                // have been possible) or an object was created and the server destroyed it
                // before it could be implemented.
                // Thus, we just create a dummy already-dead Proxy
                Object::from_interface::<I>(1, ObjectMeta::dead())
            }
        };

        ProxyInner {
            map: self.map,
            connection: self.connection,
            id: self.id,
            object,
        }
    }
// Invariants: Impl is either `Send` or we are on the same thread as the target event loop
Impl is either `Send` or we are on the same thread as the target event loop
Impl is either ` Send ` or we are on the same thread as the target event loop
pub(crate) unsafe fn implement<I: Interface, F>(
        self,
        implementation: F,
        user_data: UserData,
    ) -> ProxyInner
    where
        F: FnMut(I::Event, I) + 'static,
        I: From<Proxy<I>>,
        I::Event: MessageGroup<Map = super::ProxyMap>,
    {
        let object = self.map.lock().unwrap().with(self.id, |obj| {
            obj.meta.dispatcher = super::make_dispatcher(implementation);
            obj.meta.user_data = Arc::new(user_data);
            obj.clone()
        });
        let object = match object {
            Ok(obj) => obj,
            Err(()) => {
                // We are trying to implement a non-existent object
                // This is either a bug in the lib (a NewProxy was created while it should not
                // have been possible) or an object was created and the server destroyed it
                // before it could be implemented.
                // Thus, we just create a dummy already-dead Proxy
                Object::from_interface::<I>(1, ObjectMeta::dead())
            }
        };
        ProxyInner {
            map: self.map,
            connection: self.connection,
            id: self.id,
            object,
        }
    }
pub ( crate ) unsafe fn implement < I : Interface , F > ( self , implementation : F , user_data : UserData , ) -> ProxyInner where F : FnMut ( I :: Event , I ) + ' static , I : From < Proxy < I > > , I :: Event : MessageGroup < Map = super :: ProxyMap > , { let object = self . map . lock ( ) . unwrap ( ) . with ( self . id , | obj | { obj . meta . dispatcher = super :: make_dispatcher ( implementation ) ; obj . meta . user_data = Arc :: new ( user_data ) ; obj . clone ( ) } ) ; let object = match object { Ok ( obj ) => obj , Err ( ( ) ) => { // We are trying to implement a non-existent object // This is either a bug in the lib (a NewProxy was created while it should not // have been possible) or an object was created and the server destroyed it // before it could be implemented. // Thus, we just create a dummy already-dead Proxy Object :: from_interface :: < I > ( 1 , ObjectMeta :: dead ( ) ) } } ; ProxyInner { map : self . map , connection : self . connection , id : self . id , object , } }
Invariants: Impl is either `Send` or we are on the same thread as the target event loop
Invariants : Impl is either ` Send ` or we are on the same thread as the target event loop
self
implementation
F
user_data
UserData
self
implementation
F
user_data
UserData