pub struct NrVec<T> { /* private fields */ }Expand description
A vector with a pointer, length, and capacity.
This struct is #[repr(C)] and ABI-stable.
Owned values carry a producer-side drop callback so the receiving module
never deallocates them with the wrong allocator. Borrowed foreign values
use owned = 0 and are never freed by this type. Prefer NrBytes for
ordinary borrowed input.
Implementations§
Source§impl NrVec<u8>
impl NrVec<u8>
Sourcepub unsafe fn from_nr_bytes(bytes: NrBytes) -> Result<Self, NrViewError>
pub unsafe fn from_nr_bytes(bytes: NrBytes) -> Result<Self, NrViewError>
Copies an ABI byte view into an owned vector.
§Safety
bytes must point to readable memory for its declared length.
pub fn from_string(s: String) -> Self
Source§impl<T> NrVec<T>
impl<T> NrVec<T>
Sourcepub fn from_vec(v: Vec<T>) -> Self
pub fn from_vec(v: Vec<T>) -> Self
Takes ownership of a Rust vector without copying its allocation.
Sourcepub fn into_vec(self) -> Vec<T>where
T: Clone,
pub fn into_vec(self) -> Vec<T>where
T: Clone,
Copies the elements into a vector owned by the current module.
The source allocation is released by the allocator-specific callback
supplied by the module that created this NrVec.
pub fn capacity(&self) -> usize
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn as_ptr(&self) -> *const T
pub fn as_mut_ptr(&mut self) -> *mut T
Trait Implementations§
Source§impl<'a, T> IntoIterator for &'a NrVec<T>
impl<'a, T> IntoIterator for &'a NrVec<T>
Source§impl<T: Clone> IntoIterator for NrVec<T>
impl<T: Clone> IntoIterator for NrVec<T>
impl<T: Send> Send for NrVec<T>
impl<T: Sync> Sync for NrVec<T>
Auto Trait Implementations§
impl<T> Freeze for NrVec<T>
impl<T> RefUnwindSafe for NrVec<T>where
T: RefUnwindSafe,
impl<T> Unpin for NrVec<T>
impl<T> UnsafeUnpin for NrVec<T>
impl<T> UnwindSafe for NrVec<T>where
T: RefUnwindSafe,
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