Struct ruby_marshal::ValueArena
source · pub struct ValueArena { /* private fields */ }
Expand description
An arena of Ruby values.
Implementations§
source§impl ValueArena
impl ValueArena
sourcepub fn new() -> Self
pub fn new() -> Self
Make a new empty ValueArena
.
The root node is nil.
sourcepub fn root(&self) -> ValueHandle
pub fn root(&self) -> ValueHandle
Get the root ValueHandle
.
sourcepub fn replace_root<H>(&mut self, new_root: H) -> ValueHandlewhere
H: Into<ValueHandle>,
pub fn replace_root<H>(&mut self, new_root: H) -> ValueHandlewhere
H: Into<ValueHandle>,
Replace the current root, returning the old root.
sourcepub fn get<H>(&self, handle: H) -> Option<&Value>where
H: Into<ValueHandle>,
pub fn get<H>(&self, handle: H) -> Option<&Value>where
H: Into<ValueHandle>,
Get a reference to the Value
denoted by the given ValueHandle
.
sourcepub fn get_symbol(
&self,
handle: TypedValueHandle<SymbolValue>,
) -> Option<&SymbolValue>
pub fn get_symbol( &self, handle: TypedValueHandle<SymbolValue>, ) -> Option<&SymbolValue>
Get a reference to the SymbolValue
denoted by the given TypedValueHandle
.
§Panics
Panics if the value is not a SymbolValue.
sourcepub fn create_nil(&mut self) -> TypedValueHandle<NilValue>
pub fn create_nil(&mut self) -> TypedValueHandle<NilValue>
Create an orphan Nil
value and return the handle.
sourcepub fn create_bool(&mut self, value: bool) -> TypedValueHandle<BoolValue>
pub fn create_bool(&mut self, value: bool) -> TypedValueHandle<BoolValue>
Create an orphan Bool
value and return the handle.
sourcepub fn create_fixnum(&mut self, value: i32) -> TypedValueHandle<FixnumValue>
pub fn create_fixnum(&mut self, value: i32) -> TypedValueHandle<FixnumValue>
Create an orphan Fixnum
value and return the handle.
sourcepub fn create_symbol(&mut self, value: Vec<u8>) -> TypedValueHandle<SymbolValue>
pub fn create_symbol(&mut self, value: Vec<u8>) -> TypedValueHandle<SymbolValue>
Create an orphan Symbol
value and return the handle.
If a symbol with this name already exists in this arena, it is returned instead of creating a new symbol.
sourcepub fn create_new_symbol(
&mut self,
value: Vec<u8>,
) -> TypedValueHandle<SymbolValue>
pub fn create_new_symbol( &mut self, value: Vec<u8>, ) -> TypedValueHandle<SymbolValue>
Create a new orphan Symbol
value and return the handle.
sourcepub fn create_array(
&mut self,
value: Vec<ValueHandle>,
) -> TypedValueHandle<ArrayValue>
pub fn create_array( &mut self, value: Vec<ValueHandle>, ) -> TypedValueHandle<ArrayValue>
Create an orphan Array
value and return the handle.
sourcepub fn create_hash(
&mut self,
value: Vec<(ValueHandle, ValueHandle)>,
default_value: Option<ValueHandle>,
) -> TypedValueHandle<HashValue>
pub fn create_hash( &mut self, value: Vec<(ValueHandle, ValueHandle)>, default_value: Option<ValueHandle>, ) -> TypedValueHandle<HashValue>
Create an orphan Hash
value and return the handle.
sourcepub fn create_object(
&mut self,
name: TypedValueHandle<SymbolValue>,
instance_variables: Vec<(TypedValueHandle<SymbolValue>, ValueHandle)>,
) -> TypedValueHandle<ObjectValue>
pub fn create_object( &mut self, name: TypedValueHandle<SymbolValue>, instance_variables: Vec<(TypedValueHandle<SymbolValue>, ValueHandle)>, ) -> TypedValueHandle<ObjectValue>
Create an orphan Object
value and return the handle.
sourcepub fn create_string(&mut self, value: Vec<u8>) -> TypedValueHandle<StringValue>
pub fn create_string(&mut self, value: Vec<u8>) -> TypedValueHandle<StringValue>
Create an orphan String
value and return the handle.
sourcepub fn create_user_defined(
&mut self,
name: TypedValueHandle<SymbolValue>,
value: Vec<u8>,
) -> TypedValueHandle<UserDefinedValue>
pub fn create_user_defined( &mut self, name: TypedValueHandle<SymbolValue>, value: Vec<u8>, ) -> TypedValueHandle<UserDefinedValue>
Create an orphan UserDefined
value and return the handle.