pub trait StableApiDefinition {
const VERSION_MAJOR: u32;
const VERSION_MINOR: u32;
Show 40 methods
// Required methods
unsafe fn rstring_len(&self, obj: VALUE) -> c_long;
unsafe fn rstring_ptr(&self, obj: VALUE) -> *const c_char;
unsafe fn rarray_len(&self, obj: VALUE) -> c_long;
unsafe fn rarray_const_ptr(&self, obj: VALUE) -> *const VALUE;
unsafe fn rbasic_class(&self, obj: VALUE) -> Option<NonNull<VALUE>>;
unsafe fn frozen_p(&self, obj: VALUE) -> bool;
unsafe fn bignum_positive_p(&self, obj: VALUE) -> bool;
fn special_const_p(&self, value: VALUE) -> bool;
unsafe fn builtin_type(&self, obj: VALUE) -> ruby_value_type;
unsafe fn type_p(&self, obj: VALUE, ty: ruby_value_type) -> bool;
fn nil_p(&self, obj: VALUE) -> bool;
fn fixnum_p(&self, obj: VALUE) -> bool;
unsafe fn dynamic_sym_p(&self, obj: VALUE) -> bool;
fn static_sym_p(&self, obj: VALUE) -> bool;
unsafe fn symbol_p(&self, obj: VALUE) -> bool;
unsafe fn float_type_p(&self, obj: VALUE) -> bool;
unsafe fn integer_type_p(&self, obj: VALUE) -> bool;
fn flonum_p(&self, obj: VALUE) -> bool;
fn immediate_p(&self, obj: VALUE) -> bool;
fn rb_test(&self, ob: VALUE) -> bool;
unsafe fn rb_type(&self, obj: VALUE) -> ruby_value_type;
unsafe fn rstring_interned_p(&self, obj: VALUE) -> bool;
fn thread_sleep(&self, duration: Duration);
unsafe fn rtypeddata_p(&self, obj: VALUE) -> bool;
unsafe fn rtypeddata_embedded_p(&self, obj: VALUE) -> bool;
unsafe fn rtypeddata_type(&self, obj: VALUE) -> *const rb_data_type_t;
unsafe fn rtypeddata_get_data(&self, obj: VALUE) -> *mut c_void;
fn fix2long(&self, obj: VALUE) -> c_long;
fn fix2ulong(&self, obj: VALUE) -> c_ulong;
fn long2fix(&self, val: c_long) -> VALUE;
fn fixable(&self, val: c_long) -> bool;
fn posfixable(&self, val: c_ulong) -> bool;
unsafe fn num2long(&self, obj: VALUE) -> c_long;
unsafe fn num2ulong(&self, obj: VALUE) -> c_ulong;
fn long2num(&self, val: c_long) -> VALUE;
fn ulong2num(&self, val: c_ulong) -> VALUE;
fn id2sym(&self, id: ID) -> VALUE;
unsafe fn sym2id(&self, obj: VALUE) -> ID;
// Provided methods
fn version(&self) -> (u32, u32) { ... }
unsafe fn bignum_negative_p(&self, obj: VALUE) -> bool { ... }
}Required Associated Constants§
const VERSION_MAJOR: u32
const VERSION_MINOR: u32
Required Methods§
Sourceunsafe fn rstring_len(&self, obj: VALUE) -> c_long
unsafe fn rstring_len(&self, obj: VALUE) -> c_long
Get the length of a Ruby string (akin to RSTRING_LEN).
§Safety
This function is unsafe because it dereferences a raw pointer to get access to underlying Ruby data. The caller must ensure that the pointer is valid.
Sourceunsafe fn rstring_ptr(&self, obj: VALUE) -> *const c_char
unsafe fn rstring_ptr(&self, obj: VALUE) -> *const c_char
Get a pointer to the bytes of a Ruby string (akin to RSTRING_PTR).
§Safety
This function is unsafe because it dereferences a raw pointer to get access to underlying Ruby data. The caller must ensure that the pointer is valid.
Sourceunsafe fn rarray_len(&self, obj: VALUE) -> c_long
unsafe fn rarray_len(&self, obj: VALUE) -> c_long
Get the length of a Ruby array (akin to RARRAY_LEN).
§Safety
This function is unsafe because it dereferences a raw pointer to get access to underlying Ruby data. The caller must ensure that the pointer is valid.
Sourceunsafe fn rarray_const_ptr(&self, obj: VALUE) -> *const VALUE
unsafe fn rarray_const_ptr(&self, obj: VALUE) -> *const VALUE
Get a pointer to the elements of a Ruby array (akin to RARRAY_CONST_PTR).
§Safety
This function is unsafe because it dereferences a raw pointer to get access to underlying Ruby data. The caller must ensure that the pointer is valid.
Sourceunsafe fn rbasic_class(&self, obj: VALUE) -> Option<NonNull<VALUE>>
unsafe fn rbasic_class(&self, obj: VALUE) -> Option<NonNull<VALUE>>
Get the class from a VALUE which contains an RBasic struct.
VALUE is a valid pointer to a non-immediate object.
§Safety
This function is unsafe because it dereferences a raw pointer to get
access to underlying RBasic struct. The caller must ensure that the
VALUE is a valid pointer to an RBasic struct.
Sourceunsafe fn frozen_p(&self, obj: VALUE) -> bool
unsafe fn frozen_p(&self, obj: VALUE) -> bool
Checks if the given object is frozen.
VALUE is a valid pointer to a non-immediate object.
§Safety
This function is unsafe because it may dereference a raw pointer to get
access to underlying RBasic struct. The caller must ensure that the
VALUE is a valid pointer to an RBasic struct.
Sourceunsafe fn bignum_positive_p(&self, obj: VALUE) -> bool
unsafe fn bignum_positive_p(&self, obj: VALUE) -> bool
Tests if a bignum is positive.
§Safety
This function is unsafe because it dereferences a raw pointer to get
access to underlying RBasic struct. The caller must ensure that the
VALUE is a valid pointer to a bignum.
Sourcefn special_const_p(&self, value: VALUE) -> bool
fn special_const_p(&self, value: VALUE) -> bool
Tests if the given value is a special constant.
Sourceunsafe fn builtin_type(&self, obj: VALUE) -> ruby_value_type
unsafe fn builtin_type(&self, obj: VALUE) -> ruby_value_type
Sourceunsafe fn type_p(&self, obj: VALUE, ty: ruby_value_type) -> bool
unsafe fn type_p(&self, obj: VALUE, ty: ruby_value_type) -> bool
Tests if the object’s type is the given type.
§Safety
This function is unsafe because it could dereference a raw pointer when
attemping to access the underlying [RBasic] struct.
Sourceunsafe fn dynamic_sym_p(&self, obj: VALUE) -> bool
unsafe fn dynamic_sym_p(&self, obj: VALUE) -> bool
Checks if the given object is a dynamic symbol.
§Safety
This function is unsafe because it could dereference a raw pointer when
attemping to access the underlying [RBasic] struct.
Sourcefn static_sym_p(&self, obj: VALUE) -> bool
fn static_sym_p(&self, obj: VALUE) -> bool
Checks if the given object is a static symbol.
Sourceunsafe fn symbol_p(&self, obj: VALUE) -> bool
unsafe fn symbol_p(&self, obj: VALUE) -> bool
Checks if the given object is a symbol.
§Safety
This function is unsafe because it could dereference a raw pointer when
attemping to access the underlying [RBasic] struct.
Sourceunsafe fn float_type_p(&self, obj: VALUE) -> bool
unsafe fn float_type_p(&self, obj: VALUE) -> bool
Checks if the given object is a so-called Flonum.
§Safety
This function is unsafe because it could dereference a raw pointer when
attemping to access the underlying [RBasic] struct.
Sourceunsafe fn integer_type_p(&self, obj: VALUE) -> bool
unsafe fn integer_type_p(&self, obj: VALUE) -> bool
Checks if the given object is an integer type
§Safety
This function is unsafe because it could dereference a raw pointer when
attemping to access the underlying [RBasic] struct.
Sourcefn immediate_p(&self, obj: VALUE) -> bool
fn immediate_p(&self, obj: VALUE) -> bool
Checks if the given object is an immediate i.e. an object which has no corresponding storage inside of the object space.
Sourcefn rb_test(&self, ob: VALUE) -> bool
fn rb_test(&self, ob: VALUE) -> bool
Emulates Ruby’s “if” statement by testing if the given obj is neither Qnil or Qfalse.
§Safety
This function is unsafe because it could dereference a raw pointer when
attemping to access the underlying [RBasic] struct.
Sourceunsafe fn rb_type(&self, obj: VALUE) -> ruby_value_type
unsafe fn rb_type(&self, obj: VALUE) -> ruby_value_type
Queries the type of the object. Identical to StableApi.builtin_type,
except it can also accept special constants.
§Safety
This function is unsafe because it could dereference a raw pointer when
attemping to access the underlying [RBasic] struct.
Sourceunsafe fn rstring_interned_p(&self, obj: VALUE) -> bool
unsafe fn rstring_interned_p(&self, obj: VALUE) -> bool
Check if a Ruby string is interned (akin to RSTRING_FSTR).
§Safety
This function is unsafe because it dereferences a raw pointer to get
access to underlying flags of the RString. The caller must ensure that
the VALUE is a valid pointer to an RString.
Sourcefn thread_sleep(&self, duration: Duration)
fn thread_sleep(&self, duration: Duration)
Blocks the current thread until the given duration has passed.
Sourceunsafe fn rtypeddata_p(&self, obj: VALUE) -> bool
unsafe fn rtypeddata_p(&self, obj: VALUE) -> bool
Checks if the given object is an RTypedData.
§Safety
This function is unsafe because it dereferences a raw pointer to get access to underlying Ruby data. The caller must ensure that the pointer is valid and points to a T_DATA object.
Sourceunsafe fn rtypeddata_embedded_p(&self, obj: VALUE) -> bool
unsafe fn rtypeddata_embedded_p(&self, obj: VALUE) -> bool
Checks if the given RTypedData is embedded.
§Safety
This function is unsafe because it dereferences a raw pointer to get access to underlying Ruby data. The caller must ensure that the pointer is valid and points to an RTypedData object.
Sourceunsafe fn rtypeddata_type(&self, obj: VALUE) -> *const rb_data_type_t
unsafe fn rtypeddata_type(&self, obj: VALUE) -> *const rb_data_type_t
Gets the data type from an RTypedData object.
§Safety
This function is unsafe because it dereferences a raw pointer to get access to underlying Ruby data. The caller must ensure that the pointer is valid and points to an RTypedData object.
Sourceunsafe fn rtypeddata_get_data(&self, obj: VALUE) -> *mut c_void
unsafe fn rtypeddata_get_data(&self, obj: VALUE) -> *mut c_void
Gets the data pointer from an RTypedData object.
§Safety
This function is unsafe because it dereferences a raw pointer to get access to underlying Ruby data. The caller must ensure that the pointer is valid and points to an RTypedData object.
Sourcefn fix2long(&self, obj: VALUE) -> c_long
fn fix2long(&self, obj: VALUE) -> c_long
Convert Fixnum to long (akin to FIX2LONG).
Extracts the integer value from a Fixnum VALUE.
§Safety assumptions
objmust be a valid Fixnum VALUE
Sourcefn fix2ulong(&self, obj: VALUE) -> c_ulong
fn fix2ulong(&self, obj: VALUE) -> c_ulong
Convert Fixnum to unsigned long (akin to FIX2ULONG).
Extracts the unsigned integer value from a Fixnum VALUE.
§Safety assumptions
objmust be a valid positive Fixnum VALUE
Sourcefn long2fix(&self, val: c_long) -> VALUE
fn long2fix(&self, val: c_long) -> VALUE
Convert long to Fixnum (akin to LONG2FIX).
Creates a Fixnum VALUE from a long integer.
§Safety assumptions
valmust be in the valid Fixnum range
Sourcefn fixable(&self, val: c_long) -> bool
fn fixable(&self, val: c_long) -> bool
Check if long value can be represented as Fixnum (akin to FIXABLE).
Returns true if the value fits in a Fixnum.
Sourcefn posfixable(&self, val: c_ulong) -> bool
fn posfixable(&self, val: c_ulong) -> bool
Check if unsigned long value can be represented as positive Fixnum (akin to POSFIXABLE).
Returns true if the value fits in a positive Fixnum.
Sourceunsafe fn num2long(&self, obj: VALUE) -> c_long
unsafe fn num2long(&self, obj: VALUE) -> c_long
Convert Ruby Integer to long (akin to NUM2LONG).
Converts any Ruby Integer (Fixnum or Bignum) to a C long. May raise an exception if the value is out of range.
§Safety
objmust be a valid Integer VALUE- May call into Ruby runtime (for Bignum conversion)
Sourceunsafe fn num2ulong(&self, obj: VALUE) -> c_ulong
unsafe fn num2ulong(&self, obj: VALUE) -> c_ulong
Convert Ruby Integer to unsigned long (akin to NUM2ULONG).
Converts any Ruby Integer (Fixnum or Bignum) to a C unsigned long. May raise an exception if the value is out of range or negative.
§Safety
objmust be a valid Integer VALUE- May call into Ruby runtime (for Bignum conversion)
Sourcefn long2num(&self, val: c_long) -> VALUE
fn long2num(&self, val: c_long) -> VALUE
Convert long to Ruby Integer (akin to LONG2NUM).
Creates a Ruby Integer (Fixnum or Bignum) from a C long. Uses Fixnum if possible, otherwise allocates a Bignum.
Sourcefn ulong2num(&self, val: c_ulong) -> VALUE
fn ulong2num(&self, val: c_ulong) -> VALUE
Convert unsigned long to Ruby Integer (akin to ULONG2NUM).
Creates a Ruby Integer (Fixnum or Bignum) from a C unsigned long. Uses Fixnum if possible, otherwise allocates a Bignum.
Provided Methods§
fn version(&self) -> (u32, u32)
Sourceunsafe fn bignum_negative_p(&self, obj: VALUE) -> bool
unsafe fn bignum_negative_p(&self, obj: VALUE) -> bool
Tests if a bignum is negative.
§Safety
This function is unsafe because it dereferences a raw pointer to get
access to underlying RBasic struct. The caller must ensure that the
VALUE is a valid pointer to a bignum.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.