pub struct RSidecar;Expand description
Marker type for enabling R sidecar accessors in an ExternalPtr struct.
When used with #[derive(ExternalPtr)] and #[r_data], this field acts as
a selector that enables R-facing accessors for sibling #[r_data] fields.
§Supported Field Types
Sidecar<T>- a typed value kept in the external pointer’s protection list (not in the struct), so the pointer roots it andsaveRDS()writes it; Rust reads and writes it through the accessors the derive generatesi32,f64,bool,u8- scalars read withRf_as*on write and returned as a fresh length-1 vector on read- Any
IntoR + TryFromSexptype - converted on every read and write (e.g.,String,Vec<T>) Computed- a read-only field computed from the Rust value by a getter function (#[r_data(get = "Self::f")])
#[r_data(read_only)] on a public field of the first three kinds makes
it read-only from R (#2268): R gets no setter, and the field methods, an
R6 active binding and an S7 property refuse a write as they refuse one
to a Computed field. The Rust accessors of a Sidecar field stay.
Every field but a Sidecar lives in the Rust struct, so a reader always
sees the Rust value and a writer either converts into it or gets an error.
Those values sit behind the pointer’s address, which saveRDS does not
write. Sidecar values travel with the pointer.
§Example
use miniextendr_api::externalptr::{RSidecar, Sidecar};
#[derive(ExternalPtr)]
pub struct MyType {
pub x: i32,
/// Selector field - enables R wrapper generation
#[r_data]
r: RSidecar,
/// Rooted value - MyType_get_keys() / MyType_set_keys(), and
/// `MyType::keys(&ptr)` / `MyType::set_keys(&mut ptr, v)` in Rust
#[r_data]
pub keys: Sidecar<Vec<i32>>,
/// Zero-overhead scalar - MyType_get_count() / MyType_set_count()
#[r_data]
pub count: i32,
/// Conversion type - MyType_get_name() / MyType_set_name()
#[r_data]
pub name: String,
}§Design Notes
RSidecaris a ZST (zero-sized type) - no runtime cost- Only
pub#[r_data]fields get R wrapper functions generated - Multiple
RSidecarfields in one struct is a compile error
Trait Implementations§
impl Copy for RSidecar
Source§impl Eq for RSidecar
impl Eq for RSidecar
1.0.0 (const: unstable) · Source§#[doc(hidden)]fn assert_receiver_is_total_eq(&self)
#[doc(hidden)]fn assert_receiver_is_total_eq(&self)
implementation detail of #[derive(Eq)]
Source§#[doc(hidden)]fn assert_fields_are_eq(&self)
#[doc(hidden)]fn assert_fields_are_eq(&self)
derive_eq_internals)impl StructuralPartialEq for RSidecar
impl TrivialClone for RSidecar
Auto Trait Implementations§
impl Forget for RSidecar
impl Freeze for RSidecar
impl RefUnwindSafe for RSidecar
impl Send for RSidecar
impl Sync for RSidecar
impl Unpin for RSidecar
impl UnsafeUnpin for RSidecar
impl UnwindSafe for RSidecar
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ConsumingFallible for Twhere
T: Clone,
impl<T> Printable for T
Source§impl<T> RCopy for Twhere
T: Copy,
impl<T> RCopy for Twhere
T: Copy,
Source§impl<T> RDebug for Twhere
T: Debug,
impl<T> RDebug for Twhere
T: Debug,
Source§impl<T> SizeHint for Twhere
T: ?Sized,
impl<T> SizeHint for Twhere
T: ?Sized,
Source§default fn lower_bound(&self) -> usize
default fn lower_bound(&self) -> usize
core_io_internals)[u8; 12] could return any value between 0 and
12 inclusively as a correct implementation. Read moreSource§impl<T> SizedTypeProperties for T
impl<T> SizedTypeProperties for T
Source§#[doc(hidden)]const SIZE: usize
#[doc(hidden)]const SIZE: usize
sized_type_properties)Source§#[doc(hidden)]const ALIGN: usize
#[doc(hidden)]const ALIGN: usize
sized_type_properties)Source§#[doc(hidden)]const ALIGNMENT: Alignment
#[doc(hidden)]const ALIGNMENT: Alignment
ptr_alignment_type)Source§#[doc(hidden)]const IS_ZST: bool
#[doc(hidden)]const IS_ZST: bool
sized_type_properties)Source§#[doc(hidden)]const LAYOUT: Layout
#[doc(hidden)]const LAYOUT: Layout
sized_type_properties)Source§#[doc(hidden)]const MAX_SLICE_LEN: usize
#[doc(hidden)]const MAX_SLICE_LEN: usize
sized_type_properties)[Self]. Read moreLayout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 0 bytes