[][src]Trait artichoke::prelude::Globals

pub trait Globals {
    type Value: Value;
    type Error;
    pub fn set_global_variable<T>(
        &mut self,
        name: T,
        value: &Self::Value
    ) -> Result<(), Self::Error>
    where
        T: Into<Cow<'static, [u8]>>
;
pub fn unset_global_variable<T>(
        &mut self,
        name: T
    ) -> Result<(), Self::Error>
    where
        T: Into<Cow<'static, [u8]>>
;
pub fn get_global_variable<T>(
        &mut self,
        name: T
    ) -> Result<Option<Self::Value>, Self::Error>
    where
        T: Into<Cow<'static, [u8]>>
; }

Get and set global variables on an interpreter.

Global variables can be an arbitrary Ruby value. Variable names must start with $.

Associated Types

type Value: Value[src]

Concrete value type for global variables.

type Error[src]

Concrete error type for failures manipulating global variables.

Loading content...

Required methods

pub fn set_global_variable<T>(
    &mut self,
    name: T,
    value: &Self::Value
) -> Result<(), Self::Error> where
    T: Into<Cow<'static, [u8]>>, 
[src]

Set global variable pointed to by name to the given Ruby value.

Errors

If the name is not a valid global name, an error is returned.

If there is insufficient capacity in the global storage, an error is returned.

pub fn unset_global_variable<T>(&mut self, name: T) -> Result<(), Self::Error> where
    T: Into<Cow<'static, [u8]>>, 
[src]

Unset global variable pointed to by name.

Unsetting a global variable removes the name from the global storage table. Unset globals resolve to nil in the Ruby VM.

Unsetting a global that is currently unset is a no-op.

Errors

If the name is not a valid global name, an error is returned.

pub fn get_global_variable<T>(
    &mut self,
    name: T
) -> Result<Option<Self::Value>, Self::Error> where
    T: Into<Cow<'static, [u8]>>, 
[src]

Get the Ruby value stored in the global variable pointed to by name.

Getting a global that is currently unset returns Ok(None) even through a non-existent global resolves to nil in the Ruby VM.

Errors

If the name is not a valid global name, an error is returned.

Loading content...

Implementors

impl Globals for Artichoke[src]

type Value = Value

type Error = Error

pub fn unset_global_variable<T>(
    &mut self,
    name: T
) -> Result<(), <Artichoke as Globals>::Error> where
    T: Into<Cow<'static, [u8]>>, 
[src]

Unset global variable pointed to by name.

Unsetting a global variable removes the name from the global storage table. Unset globals resolve to nil in the Ruby VM.

Unsetting a global that is currently unset is a no-op.

Errors

If the name is not a valid global name, an error is returned.

Loading content...