Struct mbox::mbox::MBox
[−]
[src]
pub struct MBox<T: ?Sized + Free>(_);
A malloc-backed box. This structure allows Rust to exchange objects with C without cloning.
Methods
impl<T: ?Sized + Free> MBox<T>
[src]
unsafe fn from_raw(ptr: *mut T) -> MBox<T>
Constructs a new malloc-backed box from a pointer allocated by malloc
. The content of the
pointer must be already initialized.
fn as_ptr(&self) -> *const T
Obtains the pointer owned by the box.
fn as_mut_ptr(&mut self) -> *mut T
Obtains the mutable pointer owned by the box.
impl<T: ?Sized + Free> MBox<T>
[src]
fn into_raw(self) -> *mut T
Consumes the box and returns the original pointer.
The caller is responsible for free
ing the pointer after this.
impl<T> MBox<T>
[src]
fn new(value: T) -> MBox<T>
Constructs a new malloc-backed box, and move an initialized value into it.
impl<T> MBox<[T]>
[src]
unsafe fn from_raw_parts(value: *mut T, len: usize) -> MBox<[T]>
Constructs a new malloc-backed slice from the pointer and the length (number of items).
The malloc
ed size of the pointer must be at least len * size_of::<T>()
. The content
must already been initialized.
impl<T: Clone> MBox<[T]>
[src]
fn from_slice(slice: &[T]) -> MBox<[T]>
Creates a new malloc
-boxed slice by cloning the content of an existing slice.
impl MBox<str>
[src]
unsafe fn from_raw_utf8_parts_unchecked(value: *mut u8, len: usize) -> MBox<str>
Constructs a new malloc-backed string from the pointer and the length (number of UTF-8 code units).
The malloc
ed size of the pointer must be at least len
. The content must already been
initialized and be valid UTF-8.
unsafe fn from_raw_utf8_parts(value: *mut u8,
len: usize)
-> Result<MBox<str>, Utf8Error>
len: usize)
-> Result<MBox<str>, Utf8Error>
Constructs a new malloc-backed string from the pointer and the length (number of UTF-8 code units).
The malloc
ed size of the pointer must be at least len
. If the content does not contain
valid UTF-8, this method returns an Err
.
fn into_bytes(self) -> MBox<[u8]>
Converts the string into raw bytes.
unsafe fn from_utf8_unchecked(bytes: MBox<[u8]>) -> MBox<str>
Creates a string from raw bytes. The bytes must be valid UTF-8.
fn from_utf8(bytes: MBox<[u8]>) -> Result<MBox<str>, Utf8Error>
Creates a string from raw bytes. If the content does not contain valid UTF-8, this method
returns an Err
.
fn from_str(string: &str) -> MBox<str>
Creates a new malloc
-boxed string by cloning the content of an existing string slice.
Trait Implementations
impl<T: ?Sized + Free> Drop for MBox<T>
[src]
impl<T: ?Sized + Free> Deref for MBox<T>
[src]
type Target = T
The resulting type after dereferencing
fn deref(&self) -> &T
The method called to dereference a value
impl<T: ?Sized + Free> DerefMut for MBox<T>
[src]
fn deref_mut(&mut self) -> &mut T
The method called to mutably dereference a value
impl<T: ?Sized + Free> AsRef<T> for MBox<T>
[src]
fn as_ref(&self) -> &T
Performs the conversion.
impl<T: ?Sized + Free> AsMut<T> for MBox<T>
[src]
fn as_mut(&mut self) -> &mut T
Performs the conversion.
impl<T: ?Sized + Free> Borrow<T> for MBox<T>
[src]
impl<T: ?Sized + Free> BorrowMut<T> for MBox<T>
[src]
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T: ?Sized + Free + Unsize<U>, U: ?Sized + Free> CoerceUnsized<MBox<U>> for MBox<T>
[src]
impl<T: ?Sized + Free> Pointer for MBox<T>
[src]
fn fmt(&self, formatter: &mut Formatter) -> FormatResult
Formats the value using the given formatter.
impl<T: ?Sized + Free + Debug> Debug for MBox<T>
[src]
fn fmt(&self, formatter: &mut Formatter) -> FormatResult
Formats the value using the given formatter.
impl<T: ?Sized + Free + Display> Display for MBox<T>
[src]
fn fmt(&self, formatter: &mut Formatter) -> FormatResult
Formats the value using the given formatter.
impl<T: ?Sized + Free + Hash> Hash for MBox<T>
[src]
fn hash<H: Hasher>(&self, state: &mut H)
Feeds this value into the state given, updating the hasher as necessary.
fn hash_slice<H>(data: &[Self], state: &mut H) where H: Hasher
1.3.0
Feeds a slice of this type into the state provided.
impl<U: ?Sized + Free, T: ?Sized + Free + PartialEq<U>> PartialEq<MBox<U>> for MBox<T>
[src]
fn eq(&self, other: &MBox<U>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.
impl<T: ?Sized + Free + Eq> Eq for MBox<T>
[src]
impl<U: ?Sized + Free, T: ?Sized + Free + PartialOrd<U>> PartialOrd<MBox<U>> for MBox<T>
[src]
fn partial_cmp(&self, other: &MBox<U>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<T: ?Sized + Free + Ord> Ord for MBox<T>
[src]
fn cmp(&self, other: &Self) -> Ordering
This method returns an Ordering
between self
and other
. Read more
impl<T> From<T> for MBox<T>
[src]
impl<T: Clone> Clone for MBox<T>
[src]
fn clone(&self) -> MBox<T>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<T: Default> Default for MBox<T>
[src]
impl<T> Default for MBox<[T]>
[src]
impl<T: Clone> Clone for MBox<[T]>
[src]
fn clone(&self) -> Self
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<T> FromIterator<T> for MBox<[T]>
[src]
fn from_iter<I: IntoIterator<Item=T>>(iter: I) -> Self
Creates a value from an iterator. Read more
impl<T> IntoIterator for MBox<[T]>
[src]
type Item = T
The type of the elements being iterated over.
type IntoIter = MSliceIntoIter<T>
Which kind of iterator are we turning this into?
fn into_iter(self) -> MSliceIntoIter<T>
Creates an iterator from a value. Read more
impl<'a, T> IntoIterator for &'a MBox<[T]>
[src]
type Item = &'a T
The type of the elements being iterated over.
type IntoIter = Iter<'a, T>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Iter<'a, T>
Creates an iterator from a value. Read more
impl<'a, T> IntoIterator for &'a mut MBox<[T]>
[src]
type Item = &'a mut T
The type of the elements being iterated over.
type IntoIter = IterMut<'a, T>
Which kind of iterator are we turning this into?
fn into_iter(self) -> IterMut<'a, T>
Creates an iterator from a value. Read more
impl Default for MBox<str>
[src]
impl Clone for MBox<str>
[src]
fn clone(&self) -> Self
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<T> Boxed for MBox<T>
[src]
type Data = T
placement_new_protocol
)The kind of data that is stored in this kind of box.
type Place = MPlace<T>
placement_new_protocol
)The place that will negotiate the storage of the data.
unsafe fn finalize(filled: MPlace<T>) -> Self
placement_new_protocol
)Converts filled place into final owning value, shifting deallocation/cleanup responsibilities (if any remain), over to returned instance of Self
and forgetting filled
. Read more