Struct State

Source
pub struct State<'a, Buffer: IoWrite> { /* private fields */ }
Expand description

State of the virtual machine

Implementations§

Source§

impl<'a, Buffer: IoWrite> State<'a, Buffer>

Source

pub fn get_string_by_id(&self, id: usize) -> Option<&str>

Get string by string id

Return None if id is invalid. If id is provided by parameters, it can never be invalid and thus is safe to unwrap.

Source

pub fn create_str(&mut self, s: String) -> usize

Create a new string

Return reference id to the string which can be put into DiatomValue::Str().

Source

pub fn create_user_data(&mut self, data: Box<dyn Any + Send>) -> usize

Source

pub fn get_obj_mut( &mut self, ref_id: usize, ) -> Option<DiatomObjectMut<'_, Buffer>>

Get a mutable reference by reference id

Return None if id is invalid. If id is provided by parameters, it can never be invalid and thus is safe to unwrap.

Source

pub fn get_obj(&self, ref_id: usize) -> Option<DiatomObject<'_, Buffer>>

Same as get_obj_mut but this is immutable

This is much cheaper than a mutable borrow.

Source

pub fn print(&self, value: &DiatomValue) -> String

Source

pub fn collect_garbage(&mut self)

Immediately collect garbage

Source

pub fn pause_gc(&mut self)

Pause garbage collection

Do nothing if gc is already paused.

Source

pub fn resume_gc(&mut self)

Resume garbage collection

Do nothing if gc is not paused.

Auto Trait Implementations§

§

impl<'a, Buffer> Freeze for State<'a, Buffer>

§

impl<'a, Buffer> !RefUnwindSafe for State<'a, Buffer>

§

impl<'a, Buffer> Send for State<'a, Buffer>

§

impl<'a, Buffer> !Sync for State<'a, Buffer>

§

impl<'a, Buffer> Unpin for State<'a, Buffer>

§

impl<'a, Buffer> !UnwindSafe for State<'a, Buffer>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.