Struct ruby_marshal::ValueArena

source ·
pub struct ValueArena { /* private fields */ }
Expand description

An arena of Ruby values.

Implementations§

source§

impl ValueArena

source

pub fn new() -> Self

Make a new empty ValueArena.

The root node is nil.

source

pub fn root(&self) -> ValueHandle

Get the root ValueHandle.

source

pub fn replace_root<H>(&mut self, new_root: H) -> ValueHandle
where H: Into<ValueHandle>,

Replace the current root, returning the old root.

source

pub fn get<H>(&self, handle: H) -> Option<&Value>
where H: Into<ValueHandle>,

Get a reference to the Value denoted by the given ValueHandle.

source

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.

source

pub fn create_nil(&mut self) -> TypedValueHandle<NilValue>

Create an orphan Nil value and return the handle.

source

pub fn create_bool(&mut self, value: bool) -> TypedValueHandle<BoolValue>

Create an orphan Bool value and return the handle.

source

pub fn create_fixnum(&mut self, value: i32) -> TypedValueHandle<FixnumValue>

Create an orphan Fixnum value and return the handle.

source

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.

source

pub fn create_new_symbol( &mut self, value: Vec<u8>, ) -> TypedValueHandle<SymbolValue>

Create a new orphan Symbol value and return the handle.

source

pub fn create_array( &mut self, value: Vec<ValueHandle>, ) -> TypedValueHandle<ArrayValue>

Create an orphan Array value and return the handle.

source

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.

source

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.

source

pub fn create_string(&mut self, value: Vec<u8>) -> TypedValueHandle<StringValue>

Create an orphan String value and return the handle.

source

pub fn create_user_defined( &mut self, name: TypedValueHandle<SymbolValue>, value: Vec<u8>, ) -> TypedValueHandle<UserDefinedValue>

Create an orphan UserDefined value and return the handle.

Trait Implementations§

source§

impl Debug for ValueArena

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for ValueArena

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Index<ValueHandle> for ValueArena

§

type Output = Value

The returned type after indexing.
source§

fn index(&self, index: ValueHandle) -> &Self::Output

Performs the indexing (container[index]) operation. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.