Skip to main content

qtbridge_interfaces/qobject/
proxy_rust.rs

1// Copyright (C) 2025 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only
3
4use qtbridge_runtime::{DispatchMetaCall, QObjectHolder};
5use crate::genericrustproxy::GenericRustProxy;
6use super::proxy_cpp_bridge::QObjectProxyCpp;
7
8/* QObject trait left out on purpose */
9
10pub trait QObjectAdapter: DispatchMetaCall {}
11
12impl<T> QObjectAdapter for T
13where T: QObjectHolder<ProxyRust = QObjectProxyRust> {}
14
15pub type QObjectProxyRust = GenericRustProxy<QObjectProxyCpp, dyn QObjectAdapter>;
16
17impl<T: QObjectAdapter + 'static> qtbridge_runtime::qproxies::AdapterUpcast<T> for QObjectProxyRust {
18    fn upcast(rc: std::rc::Rc<std::cell::RefCell<T>>) -> std::rc::Rc<std::cell::RefCell<dyn QObjectAdapter>> {
19        rc
20    }
21}