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

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

Ffi-safe equivalent of std::box::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,
    },
}

Implementations

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 pin(value: T) -> Pin<RBox<T>>[src]

Constructs a Pin<RBox<T>>.

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

Notable traits for RBox<I>

impl<I> Iterator for RBox<I> where
    I: Iterator
type Item = I::Item;impl<T> Read for RBox<T> where
    T: Read
impl<T> Write for RBox<T> where
    T: Write
impl<F> Future for RBox<F> where
    F: Future + Unpin
type Output = F::Output;
[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>

Notable traits for RBox<I>

impl<I> Iterator for RBox<I> where
    I: Iterator
type Item = I::Item;impl<T> Read for RBox<T> where
    T: Read
impl<T> Write for RBox<T> where
    T: Write
impl<F> Future for RBox<F> where
    F: Future + Unpin
type Output = F::Output;
[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);

pub fn into_pin(self) -> Pin<RBox<T>>[src]

Wraps this RBox in a Pin

Trait Implementations

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

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

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

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

impl<T> BufRead for RBox<T> where
    T: BufRead
[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> Clone for RBox<T> where
    T: Clone
[src]

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

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

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

type Target = T

The resulting type after dereferencing.

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

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

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

impl<I> DoubleEndedIterator for RBox<I> where
    I: DoubleEndedIterator
[src]

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

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

impl<T> Error for RBox<T> where
    T: StdError
[src]

impl<I> ExactSizeIterator for RBox<I> where
    I: ExactSizeIterator
[src]

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

impl<T> From<RBox<T>> for Pin<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<I> FusedIterator for RBox<I> where
    I: FusedIterator
[src]

impl<F> Future for RBox<F> where
    F: Future + Unpin
[src]

type Output = F::Output

The type of value produced on completion.

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

type Kind = PK_SmartPointer

The kind of the pointer.

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

type StaticEquivalent = _static_RBox<__GetStaticEquivalent<T>>

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

impl<T> Hasher for RBox<T> where
    T: Hasher
[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> IntoReprRust for RBox<T>[src]

type ReprRust = Box<T>

The #[repr(Rust)] equivalent.

impl<I> Iterator for RBox<I> where
    I: Iterator
[src]

type Item = I::Item

The type of the elements being iterated over.

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

impl<T> OwnedPointer for RBox<T>[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> Pointer for RBox<T>[src]

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

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

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

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

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

type IsNonZeroType = False

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

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

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

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

Auto Trait Implementations

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

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

Blanket Implementations

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

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

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

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

type ROwned = T

The owned type, stored in RCow::Owned

type RBorrowed = &'a T

The borrowed type, stored in RCow::Borrowed

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

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

impl<T> GetWithMetadata for T[src]

type ForSelf = WithMetadata_<T, T>

This is always WithMetadata_<Self, Self>

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

impl<F> IntoFuture for F where
    F: Future
[src]

type Output = <F as Future>::Output

🔬 This is a nightly-only experimental API. (into_future)

The output that the future will produce on completion.

type Future = F

🔬 This is a nightly-only experimental API. (into_future)

Which kind of future are we turning this into?

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<I> IteratorExt for I where
    I: Iterator
[src]

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

impl<T> StringExt for T where
    T: Borrow<str> + ?Sized
[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<This> TransmuteElement for This where
    This: ?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, 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> TypeIdentity for T where
    T: ?Sized
[src]

type Type = T

The same type as Self. Read more

impl<This> ValidTag_Bounds for This where
    This: Debug + Clone + PartialEq<This>, 
[src]