[][src]Struct abi_stable::std_types::RBox

#[repr(C)]
pub struct RBox<T> { /* fields omitted */ }

Ffi-safe equivalent of Box<_>.

Example

Declaring a recursive datatype.

use abi_stable::{
    std_types::{RBox,RString},
    StableAbi,
};

#[repr(u8)]
#[derive(StableAbi)]
enum Command{
    SendProduct{
        id:u64,
    },
    GoProtest{
        cause:RString,
        place:RString,
    },
    SendComplaint{
        cause:RString,
        website:RString,
    },
    WithMetadata{
        command:RBox<Command>,
        metadata:RString,
    },
}

Methods

impl<T> RBox<T>[src]

pub fn new(value: T) -> Self[src]

Constucts an RBox<T> from a value.

Example

use abi_stable::std_types::RBox;

let baux=RBox::new(100);
assert_eq!(*baux,100);

pub fn from_box(p: Box<T>) -> RBox<T>[src]

Converts a Box<T> to an RBox<T>,reusing its heap allocation.

Example

use abi_stable::std_types::RBox;

let baux=Box::new(200);
let baux=RBox::from_box(baux);
assert_eq!(*baux,200);

pub fn from_move_ptr(p: MovePtr<T>) -> RBox<T>[src]

Constructs a Box<T> from a MovePtr<'_,T>.

Example

use std::mem::ManuallyDrop;
 
use abi_stable::{
    pointer_trait::OwnedPointer,
    sabi_types::RSmallBox,
    std_types::RBox,
};

let b=RSmallBox::<_,[u8;1]>::new(77u8);
let rbox:RBox<_>=b.in_move_ptr(|x| RBox::from_move_ptr(x) );
 
assert_eq!(*rbox,77);

impl<T> RBox<T>[src]

pub fn into_box(this: Self) -> Box<T>[src]

Converts this RBox<T> into a Box<T>

Allocation

If this is invoked outside of the dynamic library/binary that created the RBox<T>, it will allocate a new Box<T> and move the data into it.

Example

use abi_stable::std_types::RBox;

let baux:RBox<u32>=RBox::new(200);
let baux:Box<u32>=RBox::into_box(baux);
assert_eq!(*baux,200);

pub fn into_inner(this: Self) -> T[src]

Unwraps this Box<T> into the value it owns on the heap.

Example

use abi_stable::std_types::RBox;

let baux:RBox<u32>=RBox::new(200);
let baux:u32=RBox::into_inner(baux);
assert_eq!(baux,200);

Trait Implementations

impl<T> IntoReprRust for RBox<T>[src]

type ReprRust = Box<T>

impl<T> GetStaticEquivalent_ for RBox<T> where
    T: __StableAbi
[src]

type StaticEquivalent = _static_RBox<__GetStaticEquivalent<T>>

impl<T> SharedStableAbi for RBox<T> where
    T: __StableAbi
[src]

type IsNonZeroType = False

Whether this type has a single invalid bit-pattern. Read more

type Kind = __ValueKind

The kind of abi stability of this type,there are 2: Read more

impl<T> GetPointerKind for RBox<T>[src]

impl<T, O> CanTransmuteElement<O> for RBox<T>[src]

type TransmutedPtr = RBox<O>

The type of the pointer after it's element type has been changed.

impl<T> OwnedPointer for RBox<T>[src]

impl<T: Send> Send for RBox<T>[src]

impl<T: Sync> Sync for RBox<T>[src]

impl<T> Drop for RBox<T>[src]

impl<T> AsRef<T> for RBox<T>[src]

impl<T> AsMut<T> for RBox<T>[src]

impl<T, Inline> Into<RBox<T>> for RSmallBox<T, Inline> where
    Inline: InlineStorage
[src]

Converts a RSmallBox into an RBox,currently this allocates.

impl<T> From<Box<T>> for RBox<T>[src]

impl<T, Inline> From<RBox<T>> for RSmallBox<T, Inline> where
    Inline: InlineStorage
[src]

Converts an RBox into an RSmallBox,currently this allocates.

impl<T> Clone for RBox<T> where
    T: Clone
[src]

impl<T> Default for RBox<T> where
    T: Default
[src]

impl<T> Eq for RBox<T> where
    T: Eq
[src]

impl<T> Ord for RBox<T> where
    T: Ord
[src]

impl<T> PartialEq<RBox<T>> for RBox<T> where
    T: PartialEq
[src]

impl<T> PartialOrd<RBox<T>> for RBox<T> where
    T: PartialOrd
[src]

impl<T> Display for RBox<T> where
    T: Display
[src]

impl<T> Debug for RBox<T> where
    T: Debug
[src]

impl<T> Deref for RBox<T>[src]

type Target = T

The resulting type after dereferencing.

impl<T> DerefMut for RBox<T>[src]

impl<T> Hash for RBox<T> where
    T: Hash
[src]

impl<T> Borrow<T> for RBox<T>[src]

impl<T> BorrowMut<T> for RBox<T>[src]

impl<'de, T> Deserialize<'de> for RBox<T> where
    T: Deserialize<'de>, 
[src]

impl<T> Serialize for RBox<T> where
    T: Serialize
[src]

Auto Trait Implementations

impl<T> Unpin for RBox<T> where
    T: Unpin

impl<T> UnwindSafe for RBox<T> where
    T: RefUnwindSafe + UnwindSafe

impl<T> RefUnwindSafe for RBox<T> where
    T: RefUnwindSafe

Blanket Implementations

impl<This> GetConstGenericVTable for This where
    This: StableAbi + Eq + PartialEq<This> + Debug + Send + Sync
[src]

impl<This> StableAbi for This where
    This: SharedStableAbi<Kind = ValueKind>, 
[src]

impl<This> TransmuteElement for This where
    This: ?Sized
[src]

impl<'a, T> BorrowOwned<'a> for T where
    T: 'a + Clone
[src]

type ROwned = T

type RBorrowed = &'a T

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> TypeIdentity for T where
    T: ?Sized
[src]

type Type = T

The same type as Self. Read more

impl<T> SelfOps for T where
    T: ?Sized
[src]

impl<T> StringExt for T where
    T: Borrow<str> + ?Sized
[src]

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The error type returned when the conversion fails.

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]