Enum netsblox_vm::runtime::SimpleValue
source · pub enum SimpleValue {
Bool(bool),
Number(Number),
String(CompactString),
Image(Image),
Audio(Audio),
List(Vec<SimpleValue>),
}Variants§
Implementations§
source§impl SimpleValue
impl SimpleValue
sourcepub fn into_json<C: CustomTypes<S>, S: System<C>>(
self
) -> Result<Json, IntoJsonError<C, S>>
pub fn into_json<C: CustomTypes<S>, S: System<C>>( self ) -> Result<Json, IntoJsonError<C, S>>
Converts this SimpleValue into its equivalent JSON form.
Note that SimpleValue::Image and SimpleValue::Audio cannot be encoded as standard JSON;
for this, you may instead use SimpleValue::into_netsblox_json.
sourcepub fn from_json(value: Json) -> Result<Self, FromJsonError>
pub fn from_json(value: Json) -> Result<Self, FromJsonError>
Converts a JSON object into its equivalent SimpleValue.
Note that SimpleValue::Image and SimpleValue::Audio cannot be decoded from standard JSON;
for this, you may instead use SimpleValue::from_netsblox_json.
sourcepub fn into_netsblox_json(self) -> Json
pub fn into_netsblox_json(self) -> Json
Converts this SimpleValue into an encoded JSON equivalent suitable for communication with NetsBlox.
sourcepub fn from_netsblox_json(value: Json) -> Result<Self, FromNetsBloxJsonError>
pub fn from_netsblox_json(value: Json) -> Result<Self, FromNetsBloxJsonError>
Converts a JSON object returned from NetsBlox into its equivalent SimpleValue form.
sourcepub fn parse_number(s: &str) -> Option<Number>
pub fn parse_number(s: &str) -> Option<Number>
Parses a string into a number just as the runtime would do natively.
sourcepub fn stringify_number(v: Number) -> CompactString
pub fn stringify_number(v: Number) -> CompactString
Stringifies a number just as the runtime would do natively.
Trait Implementations§
source§impl Clone for SimpleValue
impl Clone for SimpleValue
source§fn clone(&self) -> SimpleValue
fn clone(&self) -> SimpleValue
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Debug for SimpleValue
impl Debug for SimpleValue
source§impl From<Audio> for SimpleValue
impl From<Audio> for SimpleValue
source§impl From<CheckedFloat<f64, NumberChecker>> for SimpleValue
impl From<CheckedFloat<f64, NumberChecker>> for SimpleValue
source§impl From<CompactString> for SimpleValue
impl From<CompactString> for SimpleValue
source§fn from(x: CompactString) -> Self
fn from(x: CompactString) -> Self
Converts to this type from the input type.
source§impl From<Image> for SimpleValue
impl From<Image> for SimpleValue
source§impl From<String> for SimpleValue
impl From<String> for SimpleValue
source§impl From<Vec<SimpleValue>> for SimpleValue
impl From<Vec<SimpleValue>> for SimpleValue
source§fn from(x: Vec<SimpleValue>) -> Self
fn from(x: Vec<SimpleValue>) -> Self
Converts to this type from the input type.
source§impl From<bool> for SimpleValue
impl From<bool> for SimpleValue
source§impl PartialEq for SimpleValue
impl PartialEq for SimpleValue
source§fn eq(&self, other: &SimpleValue) -> bool
fn eq(&self, other: &SimpleValue) -> bool
This method tests for
self and other values to be equal, and is used
by ==.impl Eq for SimpleValue
impl StructuralEq for SimpleValue
impl StructuralPartialEq for SimpleValue
Auto Trait Implementations§
impl RefUnwindSafe for SimpleValue
impl Send for SimpleValue
impl Sync for SimpleValue
impl Unpin for SimpleValue
impl UnwindSafe for SimpleValue
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.