pub struct Value { /* private fields */ }
Expand description
sciter::value
wrapper.
See the module-level documentation.
Implementations
sourceimpl Value
impl Value
sourcepub fn parse(val: &str) -> Result<Value, usize>
pub fn parse(val: &str) -> Result<Value, usize>
Parse a json string into value. Returns the number of chars left unparsed in case of error.
sourcepub fn parse_as(val: &str, how: VALUE_STRING_CVT_TYPE) -> Result<Value, usize>
pub fn parse_as(val: &str, how: VALUE_STRING_CVT_TYPE) -> Result<Value, usize>
Parse a json string into value. Returns the number of chars left unparsed in case of error.
sourcepub fn as_mut_ptr(&mut self) -> *mut VALUE
pub fn as_mut_ptr(&mut self) -> *mut VALUE
Returns a raw pointer to the underlaying data.
sourcepub const fn get_type(&self) -> VALUE_TYPE
pub const fn get_type(&self) -> VALUE_TYPE
Get the inner type of the value.
sourcepub const fn full_type(&self) -> (VALUE_TYPE, UINT)
pub const fn full_type(&self) -> (VALUE_TYPE, UINT)
Get the inner type and its subtype (e.g. units) of the value.
sourcepub fn isolate(&mut self)
pub fn isolate(&mut self)
Convert T_OBJECT
value type to JSON T_MAP
or T_ARRAY
types.
Also must be used if you need to pass values between different threads.
sourcepub fn clear(&mut self) -> &mut Value
pub fn clear(&mut self) -> &mut Value
Clear the value. It deallocates all assosiated structures that are not used anywhere else.
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Return the number of items in the T_ARRAY
, T_MAP
, T_FUNCTION
and T_OBJECT
value types.
sourcepub fn push<T: Into<Value>>(&mut self, src: T)
pub fn push<T: Into<Value>>(&mut self, src: T)
Append another value to the end of T_ARRAY
value.
sourcepub fn set<T: Into<Value>>(&mut self, index: usize, src: T)
pub fn set<T: Into<Value>>(&mut self, index: usize, src: T)
Insert or set value at the given index
of T_ARRAY
, T_MAP
, T_FUNCTION
and T_OBJECT
value.
sourcepub fn get(&self, index: usize) -> Value
pub fn get(&self, index: usize) -> Value
Retreive value of sub-element at index
.
T_ARRAY
- nth element of the array;T_MAP
- value of the nth key/value pair in the map;T_FUNCTION
- value of the nth argument of the function.
sourcepub fn set_item<TKey: Into<Value>, TValue: Into<Value>>(
&mut self,
key: TKey,
value: TValue
)
pub fn set_item<TKey: Into<Value>, TValue: Into<Value>>(
&mut self,
key: TKey,
value: TValue
)
Insert or set value of the sub-element by key
.
T_MAP
- sets named value in the map;T_OBJECT
- sets value of property of the object;T_FUNCTION
- sets named argument of the function;- otherwise it converts self to the map type and adds the key/value to it.
sourcepub fn get_item<T: Into<Value>>(&self, key: T) -> Value
pub fn get_item<T: Into<Value>>(&self, key: T) -> Value
Retrieve the value of a sub-element by key.
sourcepub fn keys(&self) -> KeyIterator<'_>
pub fn keys(&self) -> KeyIterator<'_>
An iterator visiting all keys of key/value pairs in the map.
T_MAP
- keys of key/value pairs in the map;T_OBJECT
- names of key/value properties in the object;T_FUNCTION
- names of arguments of the function (if any).
The iterator element type is Value
(as a key).
sourcepub fn values(&self) -> SeqIterator<'_>
pub fn values(&self) -> SeqIterator<'_>
An iterator visiting all values in arbitrary order.
T_ARRAY
- elements of the array;T_MAP
- values of key/value pairs in the map;T_OBJECT
- values of key/value properties in the object;T_FUNCTION
- values of arguments of the function.
The iterator element type is Value
.
sourcepub fn items(&self) -> Vec<(Value, Value)>
pub fn items(&self) -> Vec<(Value, Value)>
An iterator visiting all key-value pairs in arbitrary order.
The Value
must has a key-value type (map, object, function).
The iterator element type is (Value, Value)
.
sourcepub fn to_duration(&self) -> Option<f64>
pub fn to_duration(&self) -> Option<f64>
Value to duration.
sourcepub fn into_string(self) -> String
pub fn into_string(self) -> String
Value to json string (converted in-place). Subject to change.
sourcepub fn call(
&self,
this: Option<Value>,
args: &[Value],
name: Option<&str>
) -> Result<Value, VALUE_RESULT>
pub fn call(
&self,
this: Option<Value>,
args: &[Value],
name: Option<&str>
) -> Result<Value, VALUE_RESULT>
Function invocation for T_OBJECT
with UT_OBJECT_FUNCTION
value type.
Calls the tiscript function or method holded at Value
with context of this
object
that will be known as this inside that function (it is optional for global functions).
The name
here is an url or a name of the script - used for error reporting in script.
You can use the make_args!(args...)
macro which helps you
to construct script arguments from Rust types.
pub const fn is_undefined(&self) -> bool
pub const fn is_null(&self) -> bool
pub const fn is_nothing(&self) -> bool
pub const fn is_bool(&self) -> bool
pub const fn is_int(&self) -> bool
pub const fn is_float(&self) -> bool
pub const fn is_bytes(&self) -> bool
pub const fn is_string(&self) -> bool
pub const fn is_symbol(&self) -> bool
pub const fn is_error_string(&self) -> bool
pub const fn is_date(&self) -> bool
pub const fn is_currency(&self) -> bool
pub const fn is_color(&self) -> bool
pub const fn is_duration(&self) -> bool
pub const fn is_angle(&self) -> bool
pub const fn is_map(&self) -> bool
pub const fn is_array(&self) -> bool
pub const fn is_function(&self) -> bool
pub fn is_native_function(&self) -> bool
pub const fn is_object(&self) -> bool
pub const fn is_asset(&self) -> bool
sourcepub const fn is_primitive(&self) -> bool
pub const fn is_primitive(&self) -> bool
I.e. non-reference types that do not need a destructor.
pub const fn is_object_array(&self) -> bool
pub const fn is_object_map(&self) -> bool
pub const fn is_object_class(&self) -> bool
pub const fn is_object_native(&self) -> bool
pub const fn is_object_function(&self) -> bool
pub const fn is_object_error(&self) -> bool
pub const fn is_dom_element(&self) -> bool
pub const fn is_varray(&self) -> bool
pub const fn is_vmap(&self) -> bool
pub fn is_vfunction(&self) -> bool
pub const fn is_verror(&self) -> bool
Trait Implementations
sourceimpl Clone for Value
impl Clone for Value
Copies value.
All allocated objects are reference counted so copying is just a matter of increasing reference counts.
sourceimpl From<()> for Value
impl From<()> for Value
Value from nothing (()
) for empty return values.
Returns undefined
value.
sourceimpl From<SystemTime> for Value
impl From<SystemTime> for Value
Value from time/date.
sourcefn from(val: SystemTime) -> Self
fn from(val: SystemTime) -> Self
See the [VALUE_TIME::T_DATE].
sourceimpl<'a> FromIterator<&'a str> for Value
impl<'a> FromIterator<&'a str> for Value
Value from sequence of &str
.
sourcefn from_iter<I: IntoIterator<Item = &'a str>>(iterator: I) -> Self
fn from_iter<I: IntoIterator<Item = &'a str>>(iterator: I) -> Self
Creates a value from an iterator. Read more
sourceimpl FromIterator<String> for Value
impl FromIterator<String> for Value
Value from sequence of String
.
sourcefn from_iter<I: IntoIterator<Item = String>>(iterator: I) -> Self
fn from_iter<I: IntoIterator<Item = String>>(iterator: I) -> Self
Creates a value from an iterator. Read more
sourceimpl FromIterator<Value> for Value
impl FromIterator<Value> for Value
Value from sequence of Value
.
sourcefn from_iter<I: IntoIterator<Item = Value>>(iterator: I) -> Self
fn from_iter<I: IntoIterator<Item = Value>>(iterator: I) -> Self
Creates a value from an iterator. Read more
sourceimpl FromIterator<f64> for Value
impl FromIterator<f64> for Value
Value from sequence of f64
.
sourcefn from_iter<I: IntoIterator<Item = f64>>(iterator: I) -> Self
fn from_iter<I: IntoIterator<Item = f64>>(iterator: I) -> Self
Creates a value from an iterator. Read more
sourceimpl FromIterator<i32> for Value
impl FromIterator<i32> for Value
Value from sequence of i32
.
sourcefn from_iter<I: IntoIterator<Item = i32>>(iterator: I) -> Self
fn from_iter<I: IntoIterator<Item = i32>>(iterator: I) -> Self
Creates a value from an iterator. Read more
sourceimpl FromValue for Value
impl FromValue for Value
sourcefn from_value(v: &Value) -> Option<Self>
fn from_value(v: &Value) -> Option<Self>
Converts value to specified type.
sourceimpl<'a> IntoIterator for &'a Value
impl<'a> IntoIterator for &'a Value
Conversion into an Iterator
.
Adds the for
loop syntax support: for subitem in &value {]
.
impl Send for Value
sciter::Value
can be transferred across thread boundaries.
Auto Trait Implementations
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more