[][src]Struct auxtools::Value

pub struct Value {
    pub value: Value,
    // some fields omitted
}

Value represents any value a DM variable can hold, such as numbers, strings, datums, etc.

There's a lot of lifetime shenanigans going on, the gist of it is to just not keep Values around for longer than your hook's execution.

Fields

value: Value

Implementations

impl Value[src]

pub unsafe fn new(tag: ValueTag, data: ValueData) -> Value[src]

Creates a new value from raw tag and data. Use if you know what you are doing.

pub fn globals() -> Value[src]

Equivalent to DM's global.vars.

pub fn world() -> Value[src]

Equivalent to DM's world.

pub fn null() -> Value[src]

Equivalent to DM's null.

pub unsafe fn turf_by_id_unchecked(id: u32) -> Value[src]

Gets a turf by ID, without bounds checking. Use turf_by_id if you're not sure about how to check the bounds.

pub fn turf_by_id(id: u32) -> DMResult[src]

Gets a turf by ID, with bounds checking.

pub fn turf(x: u32, y: u32, z: u32) -> DMResult[src]

Gets a turf by coordinates.

pub fn get<S: Into<StringRef>>(&self, name: S) -> DMResult[src]

Gets a variable by name.

pub fn get_number<S: Into<StringRef>>(&self, name: S) -> ConversionResult<f32>[src]

Gets a variable by name and safely casts it to a float.

pub fn get_string<S: Into<StringRef>>(
    &self,
    name: S
) -> ConversionResult<String>
[src]

Gets a variable by name and safely casts it to a string.

pub fn get_list<S: Into<StringRef>>(&self, name: S) -> ConversionResult<List>[src]

Gets a variable by name and safely casts it to a list::List.

pub fn set<S: Into<StringRef>, V: IntoRawValue>(&self, name: S, new_value: V)[src]

Sets a variable by name to a given value.

pub fn as_number(&self) -> ConversionResult<f32>[src]

Check if the current value is a number and casts it.

pub fn as_string(&self) -> ConversionResult<String>[src]

Check if the current value is a string and casts it.

pub fn as_list(&self) -> ConversionResult<List>[src]

Check if the current value is a list and casts it.

pub fn call<S: AsRef<str>, V: AsRef<Self>>(
    &self,
    procname: S,
    args: &[V]
) -> DMResult
[src]

Calls a method of the value with the given arguments.

Examples:

This example is equivalent to src.explode(3) in DM.

This example is not tested
src.call("explode", &[&Value::from(3.0)]);

pub fn to_string(&self) -> ConversionResult<String>[src]

pub fn get_type(&self) -> Result<String, Runtime>[src]

Gets the type of the Value as a string

pub fn is_exact_type<S: AsRef<str>>(&self, typepath: S) -> bool[src]

Checks whether this Value's type is equal to typepath.

pub fn from_string<S: AsRef<str>>(data: S) -> Value[src]

Creates a Value that references a byond string. Will panic if the given string contains null bytes

Examples:

This example is not tested
let my_string = Value::from_string("Testing!");

pub unsafe fn from_raw(v: Value) -> Self[src]

blah blah lifetime is not verified with this so use at your peril

pub unsafe fn from_raw_owned(v: Value) -> Value[src]

same as from_raw but does not increment the reference count (assumes we already own this reference)

Trait Implementations

impl AsRef<Value> for Value[src]

impl Clone for Value[src]

impl Debug for Value[src]

impl Display for Value[src]

impl Drop for Value[src]

impl From<List> for Value[src]

impl From<bool> for Value[src]

impl From<f32> for Value[src]

impl From<i32> for Value[src]

impl From<u32> for Value[src]

impl FromIterator<Value> for List[src]

impl<'_> IntoRawValue for &'_ Value[src]

Auto Trait Implementations

impl RefUnwindSafe for Value

impl !Send for Value

impl !Sync for Value

impl Unpin for Value

impl UnwindSafe for Value

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.