pub struct CBox<T, TAllocator: Allocator> { /* private fields */ }Expand description
The ABI-stable box type. This type is equivalent to the standard Box type,
except it is suitable for FFI and also accepts any allocator.
Implementations§
Source§impl<T, TAllocator: Allocator> CBox<T, TAllocator>
impl<T, TAllocator: Allocator> CBox<T, TAllocator>
Sourcepub fn with_allocator(
value: T,
allocator: TAllocator,
) -> Result<Self, CBoxError>
pub fn with_allocator( value: T, allocator: TAllocator, ) -> Result<Self, CBoxError>
Sourcepub const fn data_mut(box_: &mut Self) -> &mut T
pub const fn data_mut(box_: &mut Self) -> &mut T
Returns a mutable reference to the data stored in the CBox.
Sourcepub const fn into_raw_ptr(box_: Self) -> *mut u8
pub const fn into_raw_ptr(box_: Self) -> *mut u8
Sourcepub const unsafe fn from_raw_ptr(ptr: *mut u8) -> Self
pub const unsafe fn from_raw_ptr(ptr: *mut u8) -> Self
Converts a raw pointer back to a CBox container.
§Safety
- The caller must ensure that the pointer came from the previous
call to
CBox::into_raw_ptr. - The caller must ensure that the raw pointer won’t be used after the call.
Otherwise the behavior is undefined.
Sourcepub const fn data_ptr_mut(box_: &mut Self) -> *mut T
pub const fn data_ptr_mut(box_: &mut Self) -> *mut T
Trait Implementations§
Source§impl<T, TAllocator: Allocator> BorrowMut<T> for CBox<T, TAllocator>
impl<T, TAllocator: Allocator> BorrowMut<T> for CBox<T, TAllocator>
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T, TAllocator> Clone for CBox<T, TAllocator>where
T: TryClone,
TAllocator: Allocator + TryClone,
impl<T, TAllocator> Clone for CBox<T, TAllocator>where
T: TryClone,
TAllocator: Allocator + TryClone,
Source§impl<'de, T, TAllocator: Allocator + Default> Deserialize<'de> for CBox<T, TAllocator>where
T: Deserialize<'de>,
Available on crate feature serde only.
impl<'de, T, TAllocator: Allocator + Default> Deserialize<'de> for CBox<T, TAllocator>where
T: Deserialize<'de>,
Available on crate feature
serde only.Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl<T, TAllocator> !Send for CBox<T, TAllocator>
impl<T, TAllocator> !Sync for CBox<T, TAllocator>
impl<T, TAllocator> Freeze for CBox<T, TAllocator>
impl<T, TAllocator> RefUnwindSafe for CBox<T, TAllocator>where
T: RefUnwindSafe,
TAllocator: RefUnwindSafe,
impl<T, TAllocator> Unpin for CBox<T, TAllocator>
impl<T, TAllocator> UnsafeUnpin for CBox<T, TAllocator>
impl<T, TAllocator> UnwindSafe for CBox<T, TAllocator>where
T: UnwindSafe,
TAllocator: UnwindSafe,
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