Struct dome_cloomnik::WrenVM [−][src]
This is the gate for all operations using Wren.
You can only get one in foreign methods.
Implementations
impl VM
[src]
pub fn get_context(&self) -> Context<'_>
[src]
Retrieve a [Context
] from this VM
.
pub fn ensure_slots(&self, slot_count: usize)
[src]
Ensure that there are at least slot_count
slots.
See Wren docs for more.
pub fn get_slot_count(&self) -> usize
[src]
Returns the number of available slots.
See Wren docs for more.
pub unsafe fn get_slot_type_unchecked(&self, slot: usize) -> Type
[src]
Returns the type of the object is slot
.
See Wren docs for more.
Safety
You must not provide this function a slot
that is not valid.
pub fn get_slot_type(&self, slot: usize) -> Type
[src]
Returns the type of the object is slot
.
See Wren docs for more.
pub unsafe fn set_slot_null_unchecked(&self, slot: usize)
[src]
Sets slot
to null
.
See Wren docs for more.
Safety
You must not provide this function a slot
that is not valid.
pub fn set_slot_null(&self, slot: usize)
[src]
Sets slot
to null
.
See Wren docs for more.
pub unsafe fn set_slot_bool_unchecked(&self, slot: usize, value: bool)
[src]
Sets slot
to a Bool
.
See Wren docs for more.
Safety
You must not provide this function a slot
that is not valid.
pub fn set_slot_bool(&self, slot: usize, value: bool)
[src]
Sets slot
to a Bool
.
See Wren docs for more.
pub unsafe fn set_slot_double_unchecked(&self, slot: usize, value: f64)
[src]
Sets slot
to a Num
.
See Wren docs for more.
Safety
You must not provide this function a slot
that is not valid.
pub fn set_slot_double(&self, slot: usize, value: f64)
[src]
Sets slot
to a Num
.
See Wren docs for more.
pub unsafe fn set_slot_bytes_unchecked(&self, slot: usize, data: &[u8])
[src]
Sets slot
to a String
from Rust bytes slice.
See Wren docs for more.
Safety
You must not provide this function a slot
that is not valid.
pub fn set_slot_bytes(&self, slot: usize, data: &[u8])
[src]
Sets slot
to a String
from Rust bytes slice.
See Wren docs for more.
pub unsafe fn set_slot_string_unchecked(&self, slot: usize, text: &str)
[src]
Sets slot
to a String
from Rust str
.
See Wren docs for more.
Safety
You must not provide this function a slot
that is not valid.
pub fn set_slot_string(&self, slot: usize, text: &str)
[src]
Sets slot
to a String
from Rust str
.
See Wren docs for more.
pub unsafe fn set_slot_new_list_unchecked(&self, slot: usize)
[src]
Sets slot
to a new List
.
See Wren docs for more.
Safety
You must not provide this function a slot
that is not valid.
pub fn set_slot_new_list(&self, slot: usize)
[src]
Sets slot
to a new List
.
See Wren docs for more.
pub unsafe fn set_slot_new_map_unchecked(&self, slot: usize)
[src]
Sets slot
to a new Map
.
See Wren docs for more.
Safety
You must not provide this function a slot
that is not valid.
pub fn set_slot_new_map(&self, slot: usize)
[src]
Sets slot
to a new Map
.
See Wren docs for more.
pub unsafe fn set_slot_new_raw_foreign_unchecked(
&self,
slot: usize,
class_slot: usize,
length: usize
) -> *mut c_void
[src]
&self,
slot: usize,
class_slot: usize,
length: usize
) -> *mut c_void
Sets slot
to a new foreign object, where the foreign class is stored in class_slot
and the expected size (in bytes) is length
.
See Wren docs for more.
Safety
You must not provide this function a slot
that is not valid, nor a class_slot
that is either invalid or does not contain a foreign class.
There isn't a safe counterpart to this method, because there is no way from the C API
to verify that a slot contains a foreign class ([get_slot_type()
] returns Type::Unknown
for them).
pub unsafe fn set_slot_new_foreign_unchecked<T: 'static>(
&self,
slot: usize,
class_slot: usize,
instance: T
) -> &mut T
[src]
&self,
slot: usize,
class_slot: usize,
instance: T
) -> &mut T
Sets slot
to a new Rust foreign object, where the foreign class is stored in class_slot
and the Rust type is passed as a generic parameter.
Note that this is not equal to the following:
let p = self.set_slot_new_raw_foreign_unchecked(slot, class_slot, std::mem::size_of::<T>()); std::ptr::write(p, instance);
Because this method does some bookkeeping to ensure that we get the right type back
(it stores a TypeId
), and also to work around the fact that Rust types are
required to be properly aligned, but Wren does not provide alignment guarantees.
See Wren docs for more.
Safety
You must not provide this function a slot
that is not valid, nor a class_slot
that is either invalid or does not contain a foreign class.
There isn't a safe counterpart to this method, because there is no way from the C API
to verify that a slot contains a foreign class ([get_slot_type()
] returns Type::Unknown
for them).
pub unsafe fn get_slot_bool_unchecked(&self, slot: usize) -> bool
[src]
Gets Bool
from slot
.
See Wren docs for more.
Safety
You must provide this function a slot
that is valid and contains a Bool
.
pub fn get_slot_bool(&self, slot: usize) -> bool
[src]
Gets Bool
from slot
.
See Wren docs for more.
pub unsafe fn get_slot_double_unchecked(&self, slot: usize) -> f64
[src]
Gets Num
from slot
.
See Wren docs for more.
Safety
You must provide this function a slot
that is valid and contains a Num
.
pub fn get_slot_double(&self, slot: usize) -> f64
[src]
Gets Num
from slot
.
See Wren docs for more.
pub unsafe fn get_slot_bytes_unchecked(&self, slot: usize) -> Vec<u8>
[src]
Gets a String
as a sequence of bytes from slot
.
This function copies the string and so it remains valid even after you give the control back to Wren.
See Wren docs for more.
Safety
You must provide this function a slot
that is valid and contains a String
.
pub fn get_slot_bytes(&self, slot: usize) -> Vec<u8>
[src]
Gets a String
as a sequence of bytes from slot
.
This function copies the string and so it remains valid even after you give the control back to Wren.
See Wren docs for more.
pub unsafe fn get_slot_string_unchecked(
&self,
slot: usize
) -> Result<String, Utf8Error>
[src]
&self,
slot: usize
) -> Result<String, Utf8Error>
Gets a String
as Rust String
from slot
.
Note that Rust strings are required to be valid UTF-8 sequences, but this
requirement does not exist for Wren. So, this function may fail. If you
only want a sequence of bytes (and not a textual string), you should use
[get_slot_bytes_unchecked()
].
This function copies the string and so it remains valid even after you give the control back to Wren.
See Wren docs for more.
Safety
You must provide this function a slot
that is valid and contains a String
.
pub fn get_slot_string(&self, slot: usize) -> Result<String, Utf8Error>
[src]
Gets a String
as Rust String
from slot
.
Note that Rust strings are required to be valid UTF-8 sequences, but this
requirement does not exist for Wren. So, this function may fail. If you
only want a sequence of bytes (and not a textual string), you should use
[get_slot_bytes()
].
This function copies the string and so it remains valid even after you give the control back to Wren.
See Wren docs for more.
pub unsafe fn get_slot_raw_foreign_unchecked(&self, slot: usize) -> *mut c_void
[src]
Gets a foreign object from slot
.
See Wren docs for more.
Safety
You must provide this function a slot
that is valid and contains a foreign
class instance.
pub fn get_slot_raw_foreign(&self, slot: usize) -> *mut c_void
[src]
Gets a foreign object from slot
.
See Wren docs for more.
pub unsafe fn get_slot_foreign_unchecked<T: 'static>(
&self,
slot: usize
) -> &mut T
[src]
&self,
slot: usize
) -> &mut T
Gets a Rust foreign object from slot
.
See Wren docs for more.
Safety
You must provide this function a slot
that is valid and contains a Rust foreign
class instance, created using [set_slot_new_foreign::<T>()
], with the same T
.
pub unsafe fn get_slot_foreign<T: 'static>(&self, slot: usize) -> &mut T
[src]
Gets a Rust foreign object from slot
.
See Wren docs for more.
Safety
This function is less unsafe than [get_slot_foreign_unchecked()
] because it validates
the slot it takes, so it will panic on invalid slot or if it does not contain a foreign
object, or if it does contain a Rust foreign object but not of the type T
.
See the gap? This function does validate that it got a foreign instance,
but does not validate that this instance is a Rust instance created via
[set_slot_new_foreign()
]. Verifying that is, unfortunately, impossible.
Still, you should prefer using this function over [get_slot_foreign_unchecked()
]
when performance are not a concern, because there is less risk for bugs.
pub unsafe fn get_list_count_unchecked(&self, slot: usize) -> usize
[src]
Retrieves the list length from the list object at slot
.
See Wren docs for more.
Safety
You must provide this function a slot
that is valid and contains a List
.
pub fn get_list_count(&self, slot: usize) -> usize
[src]
Retrieves the list length from the list object at slot
.
See Wren docs for more.
pub unsafe fn get_list_element_unchecked(
&self,
list_slot: usize,
index: usize,
element_slot: usize
)
[src]
&self,
list_slot: usize,
index: usize,
element_slot: usize
)
Retrieves the index-th list element from the list object at list_slot
into element_slot
.
See Wren docs for more.
Safety
You must provide this function a list_slot
that is valid and contains a List
,
a valid element_slot
, and index
that is in bounds.
pub fn get_list_element(
&self,
list_slot: usize,
index: usize,
element_slot: usize
)
[src]
&self,
list_slot: usize,
index: usize,
element_slot: usize
)
Retrieves the index-th list element from the list object at list_slot
into element_slot
.
See Wren docs for more.
pub unsafe fn set_list_element_unchecked(
&self,
list_slot: usize,
index: usize,
element_slot: usize
)
[src]
&self,
list_slot: usize,
index: usize,
element_slot: usize
)
Sets the index-th list element from the list object at list_slot
to element_slot
.
See Wren docs for more.
Safety
You must provide this function a list_slot
that is valid and contains a List
,
a valid element_slot
, and index
that is in bounds.
pub fn set_list_element(
&self,
list_slot: usize,
index: usize,
element_slot: usize
)
[src]
&self,
list_slot: usize,
index: usize,
element_slot: usize
)
Sets the index-th list element from the list object at list_slot
to element_slot
.
See Wren docs for more.
pub unsafe fn insert_in_list_unchecked(
&self,
list_slot: usize,
index: usize,
element_slot: usize
)
[src]
&self,
list_slot: usize,
index: usize,
element_slot: usize
)
Inserts the item at element_slot
to the list at slot
at index
.
See Wren docs for more.
Safety
You must provide this function a list_slot
that is valid and contains a List
,
a valid element_slot
, and index
that is in bounds.
pub fn insert_in_list(
&self,
list_slot: usize,
index: usize,
element_slot: usize
)
[src]
&self,
list_slot: usize,
index: usize,
element_slot: usize
)
Inserts the item at element_slot
to the list at list_slot
at index
.
See Wren docs for more.
pub unsafe fn get_map_count_unchecked(&self, slot: usize) -> usize
[src]
Gets the number of elements in the Map
at slot
.
See Wren docs for more.
Safety
You must provide this function a slot
that is valid and contains a Map
.
pub fn get_map_count(&self, slot: usize) -> usize
[src]
Gets the number of elements in the Map
at slot
.
See Wren docs for more.
pub unsafe fn get_map_value_unchecked(
&self,
map_slot: usize,
key_slot: usize,
value_slot: usize
)
[src]
&self,
map_slot: usize,
key_slot: usize,
value_slot: usize
)
Inserts the value with the key at key_slot
in the Map
at map_slot
into value_slot
.
See Wren docs for more.
Safety
You must provide this function a map_slot
that is valid and contains a Map
,
a key_slot
that is valid and contains a hashable object, and a value_slot
that is valid.
pub unsafe fn get_map_value(
&self,
map_slot: usize,
key_slot: usize,
value_slot: usize
)
[src]
&self,
map_slot: usize,
key_slot: usize,
value_slot: usize
)
Inserts the value with the key at key_slot
in the Map
at map_slot
into value_slot
.
See Wren docs for more.
Safety
The value inside key_slot
must be hashable.
pub unsafe fn set_map_value_unchecked(
&self,
map_slot: usize,
key_slot: usize,
value_slot: usize
)
[src]
&self,
map_slot: usize,
key_slot: usize,
value_slot: usize
)
Sets the value with the key at key_slot
in the Map
at map_slot
to value_slot
.
See Wren docs for more.
Safety
You must provide this function a map_slot
that is valid and contains a Map
,
a key_slot
that is valid and contains a hashable object, and a value_slot
that is valid.
pub unsafe fn set_map_value(
&self,
map_slot: usize,
key_slot: usize,
value_slot: usize
)
[src]
&self,
map_slot: usize,
key_slot: usize,
value_slot: usize
)
Sets the value with the key at key_slot
in the Map
at map_slot
to value_slot
.
See Wren docs for more.
Safety
The value inside key_slot
must be hashable.
pub unsafe fn map_contains_key_unchecked(
&self,
map_slot: usize,
key_slot: usize
) -> bool
[src]
&self,
map_slot: usize,
key_slot: usize
) -> bool
Returns true
if the Map
at map_slot
contains key_slot
.
See Wren docs for more.
Safety
You must provide this function a map_slot
that is valid and contains a Map
,
and a key_slot
that is valid and contains a hashable object.
pub unsafe fn map_contains_key(&self, map_slot: usize, key_slot: usize)
[src]
Returns true
if the Map
at map_slot
contains key_slot
.
See Wren docs for more.
Safety
The value inside key_slot
must be hashable.
pub unsafe fn remove_map_value_unchecked(
&self,
map_slot: usize,
key_slot: usize,
removed_value_slot: usize
)
[src]
&self,
map_slot: usize,
key_slot: usize,
removed_value_slot: usize
)
Removes the value with the key at key_slot
in the Map
at map_slot
and stores
the removed value at value_slot
.
See Wren docs for more.
Safety
You must provide this function a map_slot
that is valid and contains a Map
,
a key_slot
that is valid and contains a hashable object, and a value_slot
that is valid.
pub unsafe fn remove_map_value(
&self,
map_slot: usize,
key_slot: usize,
removed_value_slot: usize
)
[src]
&self,
map_slot: usize,
key_slot: usize,
removed_value_slot: usize
)
Removes the value with the key at key_slot
in the Map
at map_slot
and stores
the removed value at value_slot
.
See Wren docs for more.
Safety
The value inside key_slot
must be hashable.
pub unsafe fn abort_fiber_unchecked(&self, slot: usize)
[src]
pub fn abort_fiber(&self, slot: usize)
[src]
Aborts the current fiber with the error at slot
.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for VM
[src]
impl !Send for VM
[src]
impl !Sync for VM
[src]
impl Unpin for VM
[src]
impl UnwindSafe for VM
[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> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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>,