glib::translate

Trait FromGlibPtrBorrow

Source
pub trait FromGlibPtrBorrow<P: Ptr>: Sized {
    // Provided method
    unsafe fn from_glib_borrow(_ptr: P) -> Borrowed<Self> { ... }
}
Expand description

Translate from a pointer type by borrowing, without affecting the refcount.

The purpose of this trait is to access values inside callbacks without changing their reference status. The obtained borrow must not be accessed outside of the scope of the callback, and called procedures must not store any references to the underlying data. Safe Rust code must never obtain a mutable Rust reference.

§Safety

The implementation of this trait as well as the returned type must satisfy the same constraints together. They must not take ownership of the underlying value, copy it, and should not change its reference count. If it does, it must properly release obtained references.

The returned value, when dropped, must leave the underlying value in the same state as before from_glib_borrow was called:

  • it must not be dropped,
  • it must be the same type of reference, e.g. still floating.

For more information, refer to module level documentation.

Provided Methods§

Source

unsafe fn from_glib_borrow(_ptr: P) -> Borrowed<Self>

§Safety

See trait level notes on safety

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<P: Ptr, T: FromGlibPtrBorrow<P>> FromGlibPtrBorrow<P> for Option<T>

Source§

unsafe fn from_glib_borrow(ptr: P) -> Borrowed<Option<T>>

Implementors§

Source§

impl<T: 'static, MM: BoxedMemoryManager<Target = T>> FromGlibPtrBorrow<*mut T> for Boxed<T, MM>

Source§

impl<T: 'static, MM: SharedMemoryManager<Target = T>> FromGlibPtrBorrow<*mut T> for Shared<T, MM>