pub struct RustObjAccess<T: ?Sized> { /* private fields */ }Expand description
Manages shared access to a Rust object across the Rust/C++ boundary.
When Rust calls into C++ and C++ calls back into Rust, the inner callback
cannot re-borrow the RefCell without panicking. This struct solves
this by caching a raw pointer before crossing into C++ and restoring it as
a reference on the way back, avoiding a second borrow while preserving a
valid borrow stack per the “Stacked Borrows” aliasing model.
Implementations§
Source§impl<T: ?Sized> RustObjAccess<T>
impl<T: ?Sized> RustObjAccess<T>
Sourcepub fn new_strong(ptr: Rc<RefCell<T>>) -> Self
pub fn new_strong(ptr: Rc<RefCell<T>>) -> Self
Create an instance that hold a strong reference to the Rust object. This is the case for objects created on the QML Side (QML Element).
Sourcepub fn new_weak(ptr: Weak<RefCell<T>>) -> Self
pub fn new_weak(ptr: Weak<RefCell<T>>) -> Self
Create an instance that holds a weak (Weak<RefCell<T>>) reference to the Rust object.
This is the case for objects created on the Rust Side.
pub fn try_call_rust_with_handle<F, R>( &self, f: F, ) -> Result<R, RustObjAccessError>
pub fn try_call_rust_with_handle_mut<F, R>( &self, f: F, ) -> Result<R, RustObjAccessError>
pub fn try_store_handle_and_call_cpp<F, R>(
&self,
rust_obj: &T,
f: F,
) -> Result<R, RustObjAccessError>where
F: FnOnce() -> R,
pub fn try_store_handle_and_call_cpp_mut<F, R>(
&self,
rust_obj: &mut T,
f: F,
) -> Result<R, RustObjAccessError>where
F: FnOnce() -> R,
pub fn get_rc(&self) -> Option<Rc<RefCell<T>>>
Auto Trait Implementations§
impl<T> !Freeze for RustObjAccess<T>
impl<T> !RefUnwindSafe for RustObjAccess<T>
impl<T> !Send for RustObjAccess<T>
impl<T> !Sync for RustObjAccess<T>
impl<T> Unpin for RustObjAccess<T>where
T: ?Sized,
impl<T> UnsafeUnpin for RustObjAccess<T>where
T: ?Sized,
impl<T> !UnwindSafe for RustObjAccess<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more