[][src]Struct glsp::RData

pub struct RData { /* fields omitted */ }

The rdata primitive type.

This is a Rust value which has been moved onto the garbage-collected heap. It can be constructed using the glsp::rdata function, which consumes any 'static Rust value and returns a Root<RData>.

RData comes with several convenience features:

  • It supports interior mutability, like a RefCell.

  • It can be manually deallocated, or taken back from the garbage-collected heap, using free and take. Any attempts to access a deallocated RData from GameLisp will trigger an error.

  • It's dynamically typed: a Vec<Root<RData>> could refer to several different Rust types. (If this is undesirable, consider using RRoot instead.)

By default, rdata are opaque; GameLisp scripts can't access their fields or call their methods. Optionally, you can use RClassBuilder to configure an rdata so that it behaves more like a GameLisp obj, with properties and methods which can be invoked by GameLisp scripts.

Implementations

impl RData[src]

pub fn rclass(&self) -> Option<Rc<RClass>>[src]

Returns this RData's RClass, if any.

This is mostly useful for querying the RData's registered class name, by calling the name() method on RClass.

To associate an RClass with a particular Rust type, use RClassBuilder.

pub fn is<T>(&self) -> bool where
    T: 'static, 
[src]

Returns true if this RData is currently storing a value of type T.

If this RData's value has been freed, this method will return false.

pub fn borrow<T>(&self) -> RRef<T>[src]

Returns a shared reference to the value being stored by this RData.

Panics if the RData is not storing a value of type T; if its value has been freed; or if the value is currently mutably borrowed.

pub fn try_borrow<T>(&self) -> Result<RRef<T>, GError>[src]

Returns a shared reference to the value being stored by this RData.

Returns an Err if the RData is not storing a value of type T; if its value has been freed; or if the value is currently mutably borrowed.

pub fn borrow_mut<T>(&self) -> RRefMut<T>[src]

Returns a mutable reference to the value being stored by this RData.

Panics if the RData is not storing a value of type T; if its value has been freed; or if the value is currently borrowed.

pub fn try_borrow_mut<T>(&self) -> Result<RRefMut<T>, GError>[src]

Returns a mutable reference to the value being stored by this RData.

Returns an Err if the RData is not storing a value of type T; if its value has been freed; or if the value is currently borrowed.

pub fn take<T>(&self) -> Result<T, GError> where
    T: 'static, 
[src]

Takes the value stored in this RData and returns it.

Any future attempts to access the value will gracefully fail.

Returns an Err if the RData is not storing a value of type T; if its value has already been freed; or if it's currently borrowed.

pub fn free(&self) -> Result<(), GError>[src]

Drops the value stored by this RData.

Any future attempts to access the value will gracefully fail.

Returns an Err if the RData is currently borrowed, or if its value has already been freed.

pub fn is_freed(&self) -> bool[src]

Returns true if this RData's value has been taken or freed.

pub fn access_giter(rdata: &Root<RData>, giter: &Root<GIter>) -> Root<GIter>

Notable traits for Root<GIter>

impl Iterator for Root<GIter> type Item = Result<Val, GError>;
[src]

Creates an indexing iterator for this collection.

Equivalent to [rdata iter].

pub fn get<S, R>(&self, key: S) -> Result<R, GError> where
    R: FromVal,
    S: ToSym
[src]

Accesses the value of a property.

Equivalent to [rdata key].

pub fn get_if_present<S, R>(&self, key: S) -> Result<Option<R>, GError> where
    R: FromVal,
    S: ToSym
[src]

Accesses the value of a property, if it exists.

Equivalent to [rdata (? key)].

pub fn set<S, V>(&self, key: S, val: V) -> Result<(), GError> where
    V: IntoVal,
    S: ToSym
[src]

Mutates the property bound to the given name.

Equivalent to (= [rdata key] val).

pub fn set_if_present<S, V>(&self, key: S, val: V) -> Result<bool, GError> where
    V: IntoVal,
    S: ToSym
[src]

Mutates the property bound to the given name, if any. Returns true if the property exists.

Equivalent to (= [rdata (? key)] val).

pub fn call<S, A, R>(&self, key: S, args: A) -> Result<R, GError> where
    R: FromVal,
    A: IntoCallArgs,
    S: ToSym
[src]

Invokes a method.

Note that the args are passed by reference. They should be a reference to (), a tuple, a slice, or a fixed-size array.

Equivalent to (call-met rdata key ..args).

pub fn call_if_present<S, A, R>(
    &self,
    key: S,
    args: A
) -> Result<Option<R>, GError> where
    R: FromVal,
    A: IntoCallArgs,
    S: ToSym
[src]

Invokes a method, if it exists.

Note that the args are passed by reference. They should be a reference to (), a tuple, a slice, or a fixed-size array.

Equivalent to (call-met rdata (? key) ..args).

pub fn has_met<S>(&self, key: S) -> Result<bool, GError> where
    S: ToSym
[src]

Returns true if the given name is bound to a method.

Equivalent to (has-met? rdata key).

pub fn try_eq(&self, other: &Root<RData>) -> Result<bool, GError>[src]

Equivalent to (eq? self other).

Note that, because this may invoke an op-eq? method, it can potentially fail.

The same is true for PartialEq comparisons between RData using Rust's == operator. In that case, if an error occurs, the operator will panic.

Trait Implementations

impl Debug for RData[src]

impl Display for RData[src]

impl PartialEq<Root<RData>> for RData[src]

Auto Trait Implementations

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> Erased for T

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

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

impl<T> IntoElement<Slot> for T where
    T: IntoVal
[src]

impl<T> IntoVal for T where
    T: StaticMarker, 
[src]

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.