#[repr(C)]pub struct RTypedData {
pub basic: RBasic,
pub type_: *const rb_data_type_t,
pub typed_flag: VALUE,
pub data: *mut c_void,
}To improve API stability with ruby-head, direct usage of Ruby internal structs has been deprecated. To migrate, please replace the usage of this internal struct with its counterpart in the rb_sys::stable module. For example, instead of use rb_sys::rb_sys__Opaque__ExampleStruct;, use use rb_sys::stable::ExampleStruct;. If you need to access the internals of these items, you can use the provided rb-sys::macros instead.
Expand description
“Typed” user data. By using this, extension libraries can wrap a C struct
to make it visible from Ruby. For instance if you have a struct timeval,
and you want users to use it,
static inline const [`rb_data_type_t`] timeval_type = {
// Note that unspecified fields are 0-filled by default.
.wrap_struct_name = "timeval",
.function = {
.dmark = nullptr, // no need to mark
.dfree = RUBY_TYPED_DEFAULT_FREE, // use ruby_xfree()
.dsize = [](auto) {
return sizeof(struct timeval);
},
},
};
extern "C" void
Init_timeval(void)
{
auto klass = [`rb_define_class`]"YourName", [`rb_cObject`];
[`rb_define_alloc_func`]klass, [](auto klass) {
struct timeval *t;
auto ret = TypedData_Make_Struct(
klass, struct timeval, &timeval_type, t);
if (auto i = gettimeofday(t, nullptr); i == -1) {
[`rb_sys_fail`]"gettimeofday(3)");
}
else {
return ret;
}
});
}Generated by rb-sys for Ruby mri-x86_64-linux-gnu-3.2.3
Fields§
§basic: RBasicTo improve API stability with ruby-head, direct usage of Ruby internal structs has been deprecated. To migrate, please replace the usage of this internal struct with its counterpart in the rb_sys::stable module. For example, instead of use rb_sys::rb_sys__Opaque__ExampleStruct;, use use rb_sys::stable::ExampleStruct;. If you need to access the internals of these items, you can use the provided rb-sys::macros instead.
§The part that all ruby objects have in common.
Generated by rb-sys for Ruby mri-x86_64-linux-gnu-3.2.3
type_: *const rb_data_type_tTo improve API stability with ruby-head, direct usage of Ruby internal structs has been deprecated. To migrate, please replace the usage of this internal struct with its counterpart in the rb_sys::stable module. For example, instead of use rb_sys::rb_sys__Opaque__ExampleStruct;, use use rb_sys::stable::ExampleStruct;. If you need to access the internals of these items, you can use the provided rb-sys::macros instead.
§This field stores various information about how Ruby should handle a data. This roughly resembles a Ruby level class (apart from method definition etc.)
Generated by rb-sys for Ruby mri-x86_64-linux-gnu-3.2.3
typed_flag: VALUETo improve API stability with ruby-head, direct usage of Ruby internal structs has been deprecated. To migrate, please replace the usage of this internal struct with its counterpart in the rb_sys::stable module. For example, instead of use rb_sys::rb_sys__Opaque__ExampleStruct;, use use rb_sys::stable::ExampleStruct;. If you need to access the internals of these items, you can use the provided rb-sys::macros instead.
This has to be always 1.
@internal
§Why, then, this is not a const ::VALUE?
Generated by rb-sys for Ruby mri-x86_64-linux-gnu-3.2.3
data: *mut c_voidTo improve API stability with ruby-head, direct usage of Ruby internal structs has been deprecated. To migrate, please replace the usage of this internal struct with its counterpart in the rb_sys::stable module. For example, instead of use rb_sys::rb_sys__Opaque__ExampleStruct;, use use rb_sys::stable::ExampleStruct;. If you need to access the internals of these items, you can use the provided rb-sys::macros instead.
§Pointer to the actual C level struct that you want to wrap.
Generated by rb-sys for Ruby mri-x86_64-linux-gnu-3.2.3
Trait Implementations§
Source§impl Clone for RTypedData
impl Clone for RTypedData
Source§fn clone(&self) -> RTypedData
fn clone(&self) -> RTypedData
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more