// clang-format off // SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company // clang-format on // SPDX-FileContributor: Andrew Hayzen // // SPDX-License-Identifier: MIT OR Apache-2.0 #pragma once #include #include #include "rust/cxx.h" namespace rust::cxxqt1 { template class CxxQtType { public: explicit CxxQtType(::rust::Box&& rustObj) : m_rustObj(::std::move(rustObj)) { } virtual ~CxxQtType() = default; T const& unsafeRust() const { return *m_rustObj; } T& unsafeRustMut() { return *m_rustObj; } protected: ::rust::Box m_rustObj; }; template Inner& unsafeRustMut(Outer& outer) { return static_cast&>(outer).unsafeRustMut(); } template const Inner& unsafeRust(const Outer& outer) { return static_cast&>(outer).unsafeRust(); } }