RefGuard

Struct RefGuard 

Source
pub struct RefGuard<T: Rc> { /* private fields */ }
Expand description

A smart pointer for types from cef library.

Implementations§

Source§

impl<T: Rc> RefGuard<T>

Source

pub unsafe fn from_raw(ptr: *mut T) -> RefGuard<T>

Create RefGuard from a raw C pointer.

§Safety

This should be used to get the return value of the FFI function. This means we get the ownership of the value. The reference count of the return value is already increased when you get it. So we don’t need to increase it again manually. Using this method elsewhere may cause incorrect reference count and memory safety issues.

Source

pub unsafe fn from_raw_add_ref(ptr: *mut T) -> RefGuard<T>

Create RefGuard from a raw C pointer and increase a reference count. This should be used when you want to copy the value and create another wrapper type.

§Safety

THis should be used when you want to manually increase the reference count upon getting the raw pointer. Using this method elsewhere may cause incorrect reference count and memory safety issues.

Source

pub unsafe fn into_raw(&self) -> *mut T

§Safety

This should be used when you need to pass wrapper type to the FFI function as parameter, and it is the self type (usually the first parameter). This means we pass the ownership of the value to the function call. Using this method elsewhere may cause incorrect reference count and memory safety issues.

Source

pub unsafe fn convert<U: Rc>(&self) -> RefGuard<U>

Convert the value to another value that is also reference counted.

§Safety

This should be used when the type has type U as its base type. Using this method elsewhere may cause memory safety issues.

Trait Implementations§

Source§

impl<T: Rc> Clone for RefGuard<T>

Source§

fn clone(&self) -> RefGuard<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T> ConvertParam<*mut T> for &RefGuard<T>
where T: Sized + Rc,

Source§

fn into_raw(self) -> *mut T

Access the RefGuard and return the raw pointer without decreasing the reference count.

§Safety

This should be used when you need to pass wrapper type to the FFI function as parameter, and it is not the self type (usually the first parameter). This means we pass the ownership of the value to the function call. Using this method elsewehre may cause incorrect reference count and memory safety issues.

Source§

impl<T: Debug + Rc> Debug for RefGuard<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Rc> Deref for RefGuard<T>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &T

Dereferences the value.
Source§

impl<T: Rc> Drop for RefGuard<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<T: Rc> Send for RefGuard<T>

Source§

impl<T: Rc> Sync for RefGuard<T>

Auto Trait Implementations§

§

impl<T> Freeze for RefGuard<T>

§

impl<T> RefUnwindSafe for RefGuard<T>
where T: RefUnwindSafe,

§

impl<T> Unpin for RefGuard<T>

§

impl<T> UnwindSafe for RefGuard<T>
where T: RefUnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T, U> ConvertParam<U> for T
where T: Into<U>,

Source§

fn into_raw(self) -> U

Source§

impl<T, U> ConvertReturnValue<U> for T
where T: Into<U>,

Source§

fn wrap_result(self) -> U

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.