[−][src]Struct glsp_engine::RData
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
andtake
. Any attempts to access a deallocatedRData
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 usingRRoot
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: 'static>(&self) -> bool
[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) -> GResult<RRef<T>>
[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) -> GResult<RRefMut<T>>
[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: 'static>(&self) -> GResult<T>
[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) -> GResult<()>
[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>ⓘ
[src]
Creates an indexing iterator for this collection.
Equivalent to [rdata iter]
.
pub fn get<S, R>(&self, key: S) -> GResult<R> where
S: ToSym,
R: FromVal,
[src]
S: ToSym,
R: FromVal,
Accesses the value of a property.
Equivalent to [rdata key]
.
pub fn get_if_present<S, R>(&self, key: S) -> GResult<Option<R>> where
S: ToSym,
R: FromVal,
[src]
S: ToSym,
R: FromVal,
Accesses the value of a property, if it exists.
Equivalent to [rdata (? key)]
.
pub fn set<S, V>(&self, key: S, val: V) -> GResult<()> where
S: ToSym,
V: IntoVal,
[src]
S: ToSym,
V: IntoVal,
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) -> GResult<bool> where
S: ToSym,
V: IntoVal,
[src]
S: ToSym,
V: IntoVal,
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) -> GResult<R> where
S: ToSym,
A: IntoCallArgs,
R: FromVal,
[src]
S: ToSym,
A: IntoCallArgs,
R: FromVal,
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) -> GResult<Option<R>> where
S: ToSym,
A: IntoCallArgs,
R: FromVal,
[src]
S: ToSym,
A: IntoCallArgs,
R: FromVal,
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: ToSym>(&self, key: S) -> GResult<bool>
[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>) -> GResult<bool>
[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
Auto Trait Implementations
impl !RefUnwindSafe for RData
[src]
impl !Send for RData
[src]
impl !Sync for RData
[src]
impl Unpin for RData
[src]
impl !UnwindSafe for RData
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Erased for T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,