Struct CSemiBox

Source
pub struct CSemiBox<'a, D>
where D: DisposeRef + 'a + ?Sized,
{ /* private fields */ }
Expand description

A wrapper for pointers made by C that are now partially owned in Rust.

This is necessary to allow owned and borrowed representations of C types to be represented by the same type as they are in C with little overhead

Implementations§

Source§

impl<'a, D> CSemiBox<'a, D>
where D: DisposeRef + 'a + ?Sized,

Source

pub fn new(ptr: *mut D::RefTo) -> Self

Wrap the pointer in a CSemiBox

Source

pub unsafe fn as_ptr(&self) -> *mut D::RefTo

Returns the internal pointer

Source

pub unsafe fn unwrap(self) -> *mut D::RefTo

Returns the internal pointer

Trait Implementations§

Source§

impl<'a, D> Borrow<D> for CSemiBox<'a, D>
where D: DisposeRef + 'a, *mut D::RefTo: Into<&'a D>,

Source§

fn borrow(&self) -> &D

Immutably borrows from an owned value. Read more
Source§

impl<'a, T> Debug for CSemiBox<'a, T>
where T: Debug + DisposeRef + 'a, *mut T::RefTo: Into<&'a T>,

Source§

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

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

impl<'a, D> Deref for CSemiBox<'a, D>
where D: DisposeRef + 'a, *mut D::RefTo: Into<&'a D>,

Source§

type Target = D

The resulting type after dereferencing.
Source§

fn deref(&self) -> &D

Dereferences the value.
Source§

impl<'a, D> DerefMut for CSemiBox<'a, D>
where D: DisposeRef + 'a, *mut D::RefTo: Into<&'a D> + Into<&'a mut D>,

Source§

fn deref_mut(&mut self) -> &mut D

Mutably dereferences the value.
Source§

impl<'a, T> Display for CSemiBox<'a, T>
where T: Display + DisposeRef + 'a, *mut T::RefTo: Into<&'a T>,

Source§

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

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

impl<'a, D> Drop for CSemiBox<'a, D>
where D: DisposeRef + 'a + ?Sized,

Source§

fn drop(&mut self)

Run the destructor

Source§

impl<'a> From<&'a CStr> for CSemiBox<'a, str>

Source§

fn from(text: &'a CStr) -> CSemiBox<'a, str>

Converts to this type from the input type.
Source§

impl<'a, D> From<*mut <D as DisposeRef>::RefTo> for CSemiBox<'a, D>
where D: DisposeRef + 'a + ?Sized,

Source§

fn from(ptr: *mut D::RefTo) -> Self

Converts to this type from the input type.
Source§

impl<'a, T> PartialEq<T> for CSemiBox<'a, T>
where T: 'a + DisposeRef + PartialEq, *mut T::RefTo: Into<&'a T>,

Source§

fn eq(&self, other: &T) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

§

impl<'a, D> Freeze for CSemiBox<'a, D>
where D: ?Sized,

§

impl<'a, D> RefUnwindSafe for CSemiBox<'a, D>
where <D as DisposeRef>::RefTo: RefUnwindSafe, D: ?Sized,

§

impl<'a, D> !Send for CSemiBox<'a, D>

§

impl<'a, D> !Sync for CSemiBox<'a, D>

§

impl<'a, D> Unpin for CSemiBox<'a, D>
where D: ?Sized,

§

impl<'a, D> UnwindSafe for CSemiBox<'a, D>
where <D as DisposeRef>::RefTo: RefUnwindSafe, D: ?Sized,

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> 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<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.