Trait magnus::r_typed_data::DataTypeFunctions
source · pub trait DataTypeFunctionswhere
Self: Send + Sized,{
fn free(self: Box<Self>) { ... }
fn mark(&self) { ... }
fn size(&self) -> usize { ... }
fn compact(&self) { ... }
}
Expand description
A helper trait used to define functions associated with a DataType
.
Provided Methods§
sourcefn free(self: Box<Self>)
fn free(self: Box<Self>)
Called when the Ruby wrapper object is garbage collected.
This can be implemented to perform Ruby-specific clean up when your type is no longer referenced from Ruby, but it is likely easier to do this in a Drop implementation for your type.
The default implementation simply drops self
.
This function must not panic. The process will abort if this function panics.
sourcefn mark(&self)
fn mark(&self)
Called when Ruby marks this object as part of garbage collection.
If your type contains any Ruby values you must mark each of those values in this function to avoid them being garbage collected.
The default implementation does nothing.
This function must not panic. The process will abort if this function panics.
sourcefn size(&self) -> usize
fn size(&self) -> usize
Called by Ruby to establish the memory size of this data, to optimise when garbage collection happens.
The default implementation delegates to std::mem::size_of_val
.
This function must not panic. The process will abort if this function panics.