pub struct AsExternalPtr<T: IntoExternalPtr>(pub T);Expand description
Wrap a value and convert it to an R external pointer when returned from Rust.
Use this wrapper when you want to return a Rust value as an opaque pointer that R code can pass back to Rust functions later.
§Example
ⓘ
struct Connection { handle: u64 }
impl IntoExternalPtr for Connection { /* ... */ }
#[miniextendr]
fn open_connection(path: &str) -> AsExternalPtr<Connection> {
AsExternalPtr(Connection { handle: 42 })
}
// In R: open_connection("foo") returns an external pointerTuple Fields§
§0: TTrait Implementations§
Source§impl<T: Clone + IntoExternalPtr> Clone for AsExternalPtr<T>
impl<T: Clone + IntoExternalPtr> Clone for AsExternalPtr<T>
Source§fn clone(&self) -> AsExternalPtr<T>
fn clone(&self) -> AsExternalPtr<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T: Debug + IntoExternalPtr> Debug for AsExternalPtr<T>
impl<T: Debug + IntoExternalPtr> Debug for AsExternalPtr<T>
Source§impl<T: IntoExternalPtr> From<T> for AsExternalPtr<T>
impl<T: IntoExternalPtr> From<T> for AsExternalPtr<T>
Source§impl<T: IntoExternalPtr> IntoR for AsExternalPtr<T>
impl<T: IntoExternalPtr> IntoR for AsExternalPtr<T>
Source§type Error = Infallible
type Error = Infallible
The error type for fallible conversions. Read more
Source§fn try_into_sexp(self) -> Result<SEXP, Self::Error>
fn try_into_sexp(self) -> Result<SEXP, Self::Error>
Try to convert this value to an R SEXP. Read more
impl<T: Copy + IntoExternalPtr> Copy for AsExternalPtr<T>
Auto Trait Implementations§
impl<T> Freeze for AsExternalPtr<T>where
T: Freeze,
impl<T> RefUnwindSafe for AsExternalPtr<T>where
T: RefUnwindSafe,
impl<T> Send for AsExternalPtr<T>where
T: Send,
impl<T> Sync for AsExternalPtr<T>where
T: Sync,
impl<T> Unpin for AsExternalPtr<T>where
T: Unpin,
impl<T> UnsafeUnpin for AsExternalPtr<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for AsExternalPtr<T>where
T: 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